-
Spring Boot RestTemplate 兼容处理非 200 状态码的请求
需求 RestTemplate在处理状态码非200请求时,会抛出异常,需兼容处理异常。如:下游服务返回错误状态码401,而RestTemplate会直接报错。 代码 主要是设置RestTemplat
2024-04-06, Views: 1145 , Topics: Spring Boot RestTemplate
-
Spring Boot ObjectMapper 不返回 null 字段
需求 在使用ObjectMapper或正常Controller返回时,过滤掉值为null的字段。 代码 主要是objectMapper.setSerializationInclusion设置为Jso
2024-04-05, Views: 715 , Topics: Spring Boot
-
Spring Boot 配置多个 RestTemplate 实例
场景 工程中需要配置不同处理器的RestTemplate,比如:有些场景使用默认的ErrorHandler不处理400/500异常,有些场景需要添加Interceptors拦截器。 代码 @Conf
2024-04-04, Views: 1296 , Topics: Spring Boot RestTemplate
-
Spring Boot ControllerAdvice 如何抓取 Error 异常
需求 需要捕获OutOfMemoryError、StackOverflowError等继承于Error类的错误异常。 代码 对于抓取了Exception级别的异常,都会走到这个ControllerA
2024-04-03, Views: 726 , Topics: Spring Boot
-
Spring Boot 判断请求是否为静态资源
方法 ResourceUrlProvider的getForLookupPath方法,如果是正常RESTful的请求会返回为null,如果是静态资源则会返回对应的URL。 代码 import org.
2024-04-02, Views: 1037 , Topics: Spring Boot
-
Spring Boot 获取 URL 中 PathVariable 的值
@PathVariable @GetMapping("/api/post/{postId}") public Post getPost(@PathVariable Integer postId) {
2024-04-01, Views: 772 , Topics: Spring Boot
-
Spring Boot 判断 URL 地址是否匹配 Controller 路径
PathMatcher match方法第一个参数是Controller的地址,第二个参数是需要匹配的URL地址,可以是指定的字符串或者请求的地址。 @Contr
2024-03-29, Views: 847 , Topics: Spring Boot
-
Spring Boot 工程作为 SDK 依赖库方式自动注入 Bean 类
需求 抽取公共模块,以SDK的方式被宿主引入。在这个SDK中,自动注入@Configuration、@Bean、@Component、@Service、@Rep
2024-03-28, Views: 724 , Topics: Spring Boot
-
Spring Boot 打包成 SDK 去除 application.yaml 配置文件
Maven pom.xml 在build节点下,添加resources节点,并添加excludes规则,将application.yaml配置排除在SDK的ja
2024-03-27, Views: 1232 , Topics: Spring Boot
-
Spring Boot 报错 the request was rejected because no multipart boundary was found
错误信息 the request was rejected because no multipart boundary was found org.spri
2024-03-25, Views: 1736 , Topics: Spring Boot
-
Spring Boot 3 Thymeleaf ctx 对象
ctx Thymeleaf中提供的#ctx是WebEngineContext对象。 <p th:text="${#ctx}"></p>
2024-03-22, Views: 550 , Topics: Spring Boot Thymeleaf
-
Spring Boot 3 Thymeleaf 获取 HTTP 状态码
ctx Thymeleaf提供了#ctx可以获取Status Code。 思路 通过ctx获取到HttpServletResponse就能获取状态码了。 代码
2024-03-21, Views: 583 , Topics: Spring Boot Thymeleaf
-
Spring Boot 3 Invalid return type for async method (only Future and void supported): class java.lang.Boolean
错误信息 Invalid return type for async method (only Future and void supported): clas
2024-03-20, Views: 1383 , Topics: Spring Boot
-
Spring Boot 3.2 启用虚拟线程后 ThreadPoolTaskScheduler 报错
错误信息 *************************** APPLICATION FAILED TO START *******************
2024-03-19, Views: 1089 , Topics: Spring Boot 虚拟线程
-
Spring Boot 3 自动加载配置类新方式
说明 从Spring Boot 2.7开始,原先的自动加载方式标记为过时,Spring Boot 3中原先的方式被移除,无法通过原先的方式加载自定义自动配置类。
2024-03-18, Views: 727 , Topics: Spring Boot
-
PostgreSQL 16 编译安装
说明 以CentOS 8为例。 安装依赖 libxslt yum install libxslt-devel readline yum install readline-devel zlib y
2024-03-15, Views: 1345 , Topics: PostgreSQL
-
PostgreSQL 删除数据库时报错 ERROR: database "test" is being accessed by other users
错误信息 查询出错 (7): ERROR: database "test" is being accessed by other users DETAIL: T
2024-03-14, Views: 802 , Topics: PostgreSQL
-
Flowable 工作流集成到 Spring Boot 工程
添加依赖 全部功能 包含所有Flowable引擎的功能:Process、CMMN、DMN、IDM。 <dependency> <gro
2024-03-13, Views: 733 , Topics: Flowable Spring Boot
-
Flowable 配置不同数据库 Schema 做到数据隔离
需求 后端服务使用了PostgreSQL,有自己的数据库,不想让Flowable的数据库在业务的数据库中。 实现 使用PostgreSQL的不同Schema,但
2024-03-12, Views: 1211 , Topics: Flowable Spring Boot
-
Flowable 配置单独数据库
环境 Spring Boot 3、Flowable 7。 代码 yaml 配置 flowable: datasource: url: jdbc:po
2024-03-11, Views: 920 , Topics: Flowable Spring Boot