前言
因为服务器的jdk是1.7,而本地开发时是jdk1.8,导致打包后放到服务器启动不了。原来spring boot版本是2.1.6.RELEASE,由于spring boot2.x依赖jdk1.8(网上说的),故将spring boot降为1.x,再部署到服务器。降后版本为1.5.9.RELEASE
步骤
1.修改:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
2.因为模板引擎使用的是thymeleaf,降级之后,访问页面报错,所以也需要修改thymeleaf的依赖。原来已经有:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
现在在properties标签中加上:
!!!!!!!!!!!!
<properties>
<java.version>1.7</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.4.1</thymeleaf-layout-dialect.version>
</properties>
<!-- 这个是对的 -->
!!!!!!!!!!!
开始为:
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.0.5</thymeleaf-layout-dialect.version>
<!-- 这个有时会报错 -->
大部分页面访问没报错,但是如果使用了 <script th:inline="javascript">
的写法,控制台就会报错,thymeleaf的格式有误。所以还是只能用上面thymeleaf高一点的版本!!!!!!!!!!!!