• HOME
  • SEARCH
  • TOPICS
  • DATA

  • Spring Boot MyBatis-Plus 多数据源导致工程无法启动

    错误日志 *************************** APPLICATION FAILED TO START *************************** Descripti

    2024-04-22, Views: 2187 , Topics: Spring Boot MyBatis-Plus

  • Spring Boot MyBatis-Plus apply 自定义 where 条件

    需求 对于PostgreSQL中的数组类型,需要定制化SQL。 LambdaQueryWrapper 使用LambdaQueryWrapper的apply方法,自定义SQL。 查询Post表中top

    2024-04-19, Views: 2135 , Topics: Spring Boot MyBatis-Plus

  • Spring Boot MyBatis PostgreSQL Cannot convert the column of type TIMESTAMPTZ to requested type java.time.LocalDateTime

    错误信息 Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Req

    2024-04-18, Views: 3405 , Topics: Spring Boot MyBatis PostgreSQL

  • Spring Boot MyBatis xml SQL 小于号等特殊符号转义

    需求 Mybaits的mapper.xml文件中,需要对于<、>等特殊符号进行转义。 CDATA 使用CDATA对特殊符号进行包裹即可。 <![CDATA[ ]]> 示例 select * fro

    2024-04-17, Views: 1796 , Topics: Spring Boot MyBatis

  • Spring Data JDBC 查询指定字段

    需求 Repository默认会查询实体类中的所有字段,但这不是最佳实践。 需求:只查询部分需要的字段。 Projection 官方文档将此定义为Projection映射。 public inter

    2024-04-16, Views: 1432 , Topics: Spring Boot JDBC

  • Spring Data JDBC 报错 After saving the identifier must not be null

    错误信息 java.lang.IllegalArgumentException: After saving the identifier must not be null at org.sp

    2024-04-15, Views: 2333 , Topics: Spring Boot JDBC

  • Spring Boot SonarQube 跳过指定文件的代码覆盖率

    需求 对于Spring Security中的一些配置文件:HttpSecurity http等,无法覆盖代码测试。 排除检查 主要是sonar.exclusions配置,选择需要排除的.java文件

    2024-04-14, Views: 2496 , Topics: Spring Boot SonarQube

  • Spring Boot Long 类型返回前端多了两个零

    现象 Spring Boot接口中返回的字段中包含了Long类型,但前端收到的Long字段返回值多了两个0。 解决 给ObjectMapper添加Long类型序列化处理器。 @Configurati

    2024-04-13, Views: 1375 , Topics: Spring Boot

  • Spring Boot BigDecimal 返回时转为 String

    需求 金额字段如果以数字类型返回给前端时,JavaScript可能会丢失精度,需在服务端转为String保证精度不丢失。 代码 主要是simpleModule.addSerializer添加BigD

    2024-04-12, Views: 1479 , Topics: Spring Boot

  • Spring Boot OffsetDateTime 返回时转为 String

    需求 PostgreSQL中存储的带时区的时间字段,对应Java中为OffsetDateTime,Controller返回时没有对应的处理方法,会抛出异常。 代码 主要是simpleModule.a

    2024-04-11, Views: 1627 , Topics: Spring Boot

  • Spring Boot OpenFeign 配置 HTTPS 客户端证书

    配置代码 其中证书文件使用base64加密,以字符串形式配置在application.yaml文件中。 import lombok.RequiredArgsConstructor; import o

    2024-04-07, Views: 1810 , Topics: Spring Boot OpenFeign HTTPS

  • Spring Boot RestTemplate 兼容处理非 200 状态码的请求

    需求 RestTemplate在处理状态码非200请求时,会抛出异常,需兼容处理异常。如:下游服务返回错误状态码401,而RestTemplate会直接报错。 代码 主要是设置RestTemplat

    2024-04-06, Views: 2040 , Topics: Spring Boot RestTemplate

  • Spring Boot ObjectMapper 不返回 null 字段

    需求 在使用ObjectMapper或正常Controller返回时,过滤掉值为null的字段。 代码 主要是objectMapper.setSerializationInclusion设置为Jso

    2024-04-05, Views: 1218 , Topics: Spring Boot

  • Spring Boot 配置多个 RestTemplate 实例

    场景 工程中需要配置不同处理器的RestTemplate,比如:有些场景使用默认的ErrorHandler不处理400/500异常,有些场景需要添加Interceptors拦截器。 代码 @Conf

    2024-04-04, Views: 2207 , Topics: Spring Boot RestTemplate

  • Spring Boot ControllerAdvice 如何抓取 Error 异常

    需求 需要捕获OutOfMemoryError、StackOverflowError等继承于Error类的错误异常。 代码 对于抓取了Exception级别的异常,都会走到这个ControllerA

    2024-04-03, Views: 1242 , Topics: Spring Boot

  • Spring Boot 判断请求是否为静态资源

    方法 ResourceUrlProvider的getForLookupPath方法,如果是正常RESTful的请求会返回为null,如果是静态资源则会返回对应的URL。 代码 import org.

    2024-04-02, Views: 1631 , Topics: Spring Boot

  • Spring Boot 获取 URL 中 PathVariable 的值

    @PathVariable @GetMapping("/api/post/{postId}") public Post getPost(@PathVariable Integer postId) {

    2024-04-01, Views: 1388 , Topics: Spring Boot

  • Spring Boot 判断 URL 地址是否匹配 Controller 路径

    PathMatcher match方法第一个参数是Controller的地址,第二个参数是需要匹配的URL地址,可以是指定的字符串或者请求的地址。 @Contr

    2024-03-29, Views: 1452 , Topics: Spring Boot

  • Spring Boot 工程作为 SDK 依赖库方式自动注入 Bean 类

    需求 抽取公共模块,以SDK的方式被宿主引入。在这个SDK中,自动注入@Configuration、@Bean、@Component、@Service、@Rep

    2024-03-28, Views: 1239 , Topics: Spring Boot

  • Spring Boot 打包成 SDK 去除 application.yaml 配置文件

    Maven pom.xml 在build节点下,添加resources节点,并添加excludes规则,将application.yaml配置排除在SDK的ja

    2024-03-27, Views: 2016 , Topics: Spring Boot

  • First Prev
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • Next Last

©2025 沪ICP备18012661号-1 阿里云

Messages Sitemap GitHub