软件编程
位置:首页>> 软件编程>> java编程>> SpringBoot打jar包遇到的xml文件丢失的解决方案

SpringBoot打jar包遇到的xml文件丢失的解决方案

作者:北云洛月  发布时间:2023-04-11 23:39:06 

标签: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>

来源:https://blog.csdn.net/gs838251686/article/details/83506451

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com