• HOME
  • SEARCH
  • TOPICS
  • DATA

  • Spring Security 配置多种拦截规则

    单一配置 Spring Security 6中如果没有指定securityMatcher,默认会拦截所有路径。 @Bean SecurityFilterChain securityFilterCha

    2024-04-26, Views: 2501 , Topics: Spring Security Spring Boot

  • Spring Security 6 禁用各 Filter

    默认 Filter Security filter chain: [ DisableEncodeUrlFilter WebAsyncManagerIntegrationFilter Se

    2024-04-24, Views: 2387 , Topics: Spring Security Spring Boot

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

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

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

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

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

    2024-04-19, Views: 1933 , 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: 3163 , Topics: Spring Boot MyBatis PostgreSQL

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

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

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

  • Spring Data JDBC 查询指定字段

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

    2024-04-16, Views: 1279 , 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: 2109 , Topics: Spring Boot JDBC

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

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

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

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

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

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

  • Spring Boot BigDecimal 返回时转为 String

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

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

  • Spring Boot OffsetDateTime 返回时转为 String

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

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

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

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

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

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

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

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

  • Spring Boot ObjectMapper 不返回 null 字段

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

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

  • Spring Boot 配置多个 RestTemplate 实例

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

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

  • Spring Boot ControllerAdvice 如何抓取 Error 异常

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

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

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

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

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

  • Spring Boot 获取 URL 中 PathVariable 的值

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

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

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

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

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

  • First Prev
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • Next Last

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

Messages Sitemap GitHub