springboot打包成jar包后找不到xml,找不到主类的解决方法
请首先保证你的项目能正常运行(即不打包的时候运行无误),我们在打包时经常遇到如下问题:
springboot打包成jar包后找不到xml,找不到主类
我的解决方法
请将build文件更换为如下的文件:
<build>
<!-- 这样也可以把所有的xml文件,打包到相应位置。-->
<finalName>test</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<!-- 这里是保证主类不会找不到。-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>