SpringBoot打jar包遇到的xml文件丢失
在pom.xml的build标签中添加如下内容
指定资源路径
<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> </resource> </resources>
SpringBoot打jar包遇到的一些问题
1.访问不到jsp页面
1.1 jar包中没有jsp文件,报404错误
原因:没有添加jsp打包路径
解决方案:在pom.xml中添加如下代码
<build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/**</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/java</directory> <excludes> <exclude> **/*.java </exclude> </excludes> </resource> <resource> <directory>src/main/webapp</directory> <!--注意此次必须要放在此目录下才能被访问到 --> <targetPath>META-INF/resources</targetPath> <includes> <include>**/**</include> </includes> </resource> </resources> </build>
1.2 还是访问不到页面,但不报错,一直在加载
原因:maven编译版本问题
解决方案:将版本改为1.4.2.RELEASE(目前只有这个版本打jar包才能解析jsp)
1.3 此时若还报错
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:repackage (default) on project fulan-demo: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:repackage failed: Unable to find a single main class from the following candidates
原因:没有指定启动类的位置
解决方案:在pol.xml中指定启动类
<properties> <start-class>com.xxx.xxx.xxxApplication</start-class> </properties>
以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/gs838251686/article/details/83506451