温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

SpringBoot打jar包遇到的xml文件丢失该怎么解决

发布时间:2021-09-28 09:10:36 来源:亿速云 阅读:202 作者:柒染 栏目:开发技术

今天就跟大家聊聊有关SpringBoot打jar包遇到的xml文件丢失该怎么解决,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

SpringBoot打jar包遇到的xml文件丢失

在pom.xml的build标签中添加如下内容

指定资源路径

SpringBoot打jar包遇到的xml文件丢失该怎么解决

<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>

看完上述内容,你们对SpringBoot打jar包遇到的xml文件丢失该怎么解决有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI