问题描述
SpringBoot整合JSP,用编辑器启动SpringBoot项目,可以完美的访问,但是打成jar包方式,则访问不到jsp,比如会出现404错误。
解决办法
方法一:(亲测有用)
将打包方式修改为war形式
启动通过:
java -jar xxxx.war
方法二:(亲测有效)
修改pom.xm文件
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- maven插件到1.4版本打包成jar包可以访问jsp-->
<version>1.4.2.RELEASE</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<!-- 设置 targetPath 只能是 META-INF/resources。然后用这个版本最好指定一下启动类main函数<mainClass>,写上你项目的启动类,否则当你项目里面存在多个main方法就会报错不知道用哪个。 -->
<mainClass>com.bmd.forum.xxxxxxxxx</mainClass>
</configuration>
</plugin>
</plugin