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>