因为Spring Boot 2.x 项目搭建 (一)访问 start.spring.io 或通过IDE(如IntelliJ IDEA)的Spring Initializr向导创建项目时,只能使用jdk17以上的版本,这里我需要兼容老项目需要JDK1.8,所以进行一些定制。
修改pom.xml文件
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.7.18</version> <!-- 支持JDK 1.8的最新稳定版[6,7](@ref) -->
</parent><properties><java.version>1.8</java.version><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target>
</properties>
IDE配置(IntelliJ IDEA)
- 在File -> Project Structure中设置:
- Project SDK:JDK 1.8
- Language Level:8 - Lambdas, type annotations etc.
- 安装插件:Spring Assistant(增强Spring Boot支持)