标签:app cmd config work inf main方法 必须 div res
1,将maven打包插件的版本改为1.4.2
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.2.RELEASE</version>
</plugin>
2,配置 < resources>将webapp打包进target/classes 目录,其中< targetPath>META-INF/resources</ targetPath> 指定将webapp打包到target/classes 目录的META-INF/resources 目录下,必须这样配置,否则会出错.
设置 targetPath 只能是 META-INF/resources。然后用这个版本最好指定一下启动类main函数<mainClass>,写上你项目的启动类,否则当你项目里面存在多个main方法就会报错不知道用哪个。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.2.RELEASE</version>
<configuration>
<mainClass>XXX.XXX.SpringBootWebApplication</mainClass>
</configuration>
</plugin>
</plugins>
<!-- 配置 < resources>将webapp打包进target/classes 目录,其中< targetPath>META-INF/resources</ targetPath>
指定将webapp打包到target/classes 目录的META-INF/resources 目录下,必须这样配置,否则会出错 -->
<resources>
<resource>
<directory>src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
3,使用maven install 如果打包完成之后,用cmd命令启动jar包,然后访问该项目
打开cmd命令后,输入 java -jar xxx.jar (打的jar包所在的地址,可以直接拖过去)
如果运行没有报错,就去访问该项目吧!
springboot项目打包成jar无法访问jsp页面的解决方法
标签:app cmd config work inf main方法 必须 div res
原文地址:https://www.cnblogs.com/zhangliang88/p/12795006.html