Spring Boot开发问题汇总(不断更新中)

本文深入探讨了SpringBoot的关键技术和实际应用案例,包括日志配置、Actuator使用、异常处理、Thymeleaf模板语法、事务管理等核心知识点,并介绍了如何解决常见问题,如资源文件加载、时间处理等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、日志配置

LOG4J 2 CONFIGURATION: USING PROPERTIES FILE

Spring Boot Logging Example

Log4j Conversion Pattern Online Tester

Log4j打印日志到不同的文件

Log4j2 过滤指定级别的日志

Log4j2配置教程

日志文件分割教程

LogBack Appenders

2、Spring Boot Actuator

Spring Boot Actuator in Spring Boot 2.0

3、BeanNotOfRequiredTypeException 异常:but was actually of type 'com.sun.proxy.$Proxy17'

4、Thymleaf

Thymleaf多条件判断

<!-- th:block rather than unneeded div -->
<th:block th:switch="${status.value}">
  <div th:case="'COMPLETE'">
     <!-- print object is not active -->
  </div>
  <div th:case="'INVALID'">
     <!-- print object is not active -->
  </div>
  <div th:case="'NEW'">
     <!-- print object is new and active -->
  </div>
</th:block>

5、Spring Boot: javax.persistence.TransactionRequiredException: Executing an update/delete query

给方法加上@Transactional注解:

@Transactional
void removeTempoAccounts() {

6、Spring Boot打成jar后获取classpath下文件失败

这是因为打包后Spring试图访问文件系统路径,但无法访问JAR中的路径。 因此必须使用resource.getInputStream():

ClassPathResource resource = new ClassPathResource("application.yml");
InputStream inputStream = resource.getInputStream();
IOUtils.readLines(inputStream).forEach(System.out::println);

参考:Java: Load file from classpath in Spring Boot

7、配置

在Spring MVC 应用中如何基于Spring Profile读取不同的配置文件

基于Maven创建指定规范的配置文件

Spring boot加载多个配置文件

@PropertySources({
  @PropertySource("classpath:config.properties"),
  @PropertySource("classpath:db.properties")
 })

8、Spring启动时执行指定逻辑

Spring启动时执行指定逻辑

Spring Boot Application Startup Listener or init Method

RUNNING CODE ON SPRING BOOT STARTUP

9、Docker Spring Boot

Docker化Spring Boot应用

10、JPA

使用@JsonIgnoreProperties忽略Hibernate无用属性

11、SpringBoot时间相差8小时处理

SpringBoot时间相差8小时处理

12、Java 验证IP

Java验证IP

13、使用swagger管理Spring boot Rest API

使用swagger管理Spring boot Rest API

14、Spring Boot自定义Starter和Starter原理

如何创建Spring Boot Starter

自定义Starter官方文档

15、Spring 资源访问

Spring 资源访问剖析和策略模式应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值