idea创建Springboot项目,最低版本只能选择java8,但是生产环境的jdk是1.7。
按java8创建好之后,先把jdk改了:
按对应关系修改pom中的Springboot版本:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.17.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Sping Boot | Spring Framework | Java | Maven | Gradle |
Spring Boot 2.1.x | ||||
2.1.0.RELEASE | Spring Framework 5.1.2.RELEASE | Java 8 or 9 | 3.3+ | 4.4+ |
Spring Boot 2.0.x | ||||
2.0.6.RELEASE | Spring Framework 5.0.10.RELEASE | Java 8 or 9 | 3.2+ | 4.x |
2.0.5.RELEASE | Spring Framework 5.0.9.RELEASE | 4.x | ||
2.0.4.RELEASE | Spring Framework 5.0.8.RELEASE | 4 | ||
2.0.3.RELEASE | Spring Framework 5.0.7.RELEASE | 4 | ||
2.0.2.RELEASE | Spring Framework 5.0.6.RELEASE | 4 | ||
2.0.1.RELEASE | Spring Framework 5.0.5.RELEASE | 4 | ||
2.0.0.RELEASE | Spring Framework 5.0.4.RELEASE | 4 | ||
Spring Boot 1.5.x | ||||
1.5.17.RELEASE | Spring Framework 4.3.20.RELEASE | Java 7 | 3.2+ | [2.9, 3.x] |
1.5.16.RELEASE | Spring Framework 4.3.19.RELEASE | |||
1.5.15.RELEASE | Spring Framework 4.3.18.RELEASE | |||
1.5.14.RELEASE | Spring Framework 4.3.18.RELEASE | |||
1.5.13.RELEASE | Spring Framework 4.3.17.RELEASE | |||
1.5.12.RELEASE | Spring Framework 4.3.16.RELEASE | |||
1.5.11.RELEASE | Spring Framework 4.3.15.RELEASE | |||
1.5.10.RELEASE | Spring Framework 4.3.14.RELEASE | |||
1.5.9.RELEASE | Spring Framework 4.3.13.RELEASE | |||
1.5.8.RELEASE | Spring Framework 4.3.12.RELEASE | |||
1.5.7.RELEASE | Spring Framework 4.3.11.RELEASE | |||
1.5.6.RELEASE | Spring Framework 4.3.10.RELEASE | |||
1.5.5.RELEASE | Spring Framework 4.3.10.RELEASE | |||
1.5.4.RELEASE | Spring Framework 4.3.9.RELEASE | |||
1.5.3.RELEASE | Spring Framework 4.3.8.RELEASE | |||
1.5.2.RELEASE | Spring Framework 4.3.7.RELEASE | |||
1.5.1.RELEASE | Spring Framework 4.3.6.RELEASE | |||
1.5.0.RELEASE | Spring Framework 4.3.6.RELEASE | |||
Spring Boot 1.4.x | ||||
1.4.7.RELEASE | Spring Framework 4.3.9.RELEASE | Java 7 | 3.2+ | [1.12, 2.x] |
1.4.6.RELEASE | Spring Framework 4.3.8.RELEASE | |||
1.4.5.RELEASE | Spring Framework 4.3.7.RELEASE | |||
1.4.4.RELEASE | Spring Framework 4.3.6.RELEASE | |||
1.4.3.RELEASE | Spring Framework 4.3.5.RELEASE | |||
1.4.2.RELEASE | Spring Framework 4.3.4.RELEASE | |||
1.4.1.RELEASE | Spring Framework 4.3.3.RELEASE | |||
1.4.0.RELEASE | Spring Framework 4.3.2.RELEASE | |||
Spring Boot 1.3.x | ||||
1.3.8.RELEASE | Spring Framework 4.2.8.RELEASE | Java 7 | 3.2+ | [1.12, 2.x] |
1.3.7.RELEASE | Spring Framework 4.2.7.RELEASE | 1.12+ | ||
1.3.6.RELEASE | Spring Framework 4.2.7.RELEASE | |||
1.3.5.RELEASE | Spring Framework 4.2.6.RELEASE | |||
1.3.4.RELEASE | Spring Framework 4.2.6.RELEASE | |||
1.3.3.RELEASE | Spring Framework 4.1.5 or above | |||
1.3.2.RELEASE | ||||
1.3.1.RELEASE | ||||
1.3.0.RELEASE | ||||
Spring Boot 1.2.x | ||||
1.2.8.RELEASE | Spring Framework 4.1.5 or above | Java 7 | 3.2+ | 1.12+ |
1.2.7.RELEASE | ||||
1.2.6.RELEASE | ||||
1.2.5.RELEASE | ||||
1.2.4.RELEASE | ||||
1.2.3.RELEASE | ||||
1.2.2.RELEASE | ||||
1.2.1.RELEASE | Spring Framework 4.1.3 or above | Java 6 | ||
1.2.0.RELEASE |
直接修改<parent>标签的版本可能不会生效,需要先将starter依赖注释,reload maven,还不行的话重启下idea。
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-jdbc</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
如果是打成war包,SpringBootServletInitializer需要修改,将引用里的servlet去掉即可:
jar包降级:
application配置文件修改:
server.servlet.context-path改为server.context-path
server:
port: 8888
context-path: /app
配置修改结束,运行成功!