今天打完项目jar,Linux启动时,发现总是报错,找不到application.properties配置文件:
class path resource [applicationContext.xml] cannot be
opened because it does not exist
推测原因是打包未扫描(没有找到)到这个配置文件,修改办法如下:
添加pom文件中的打包资源即可:
<resources>
<!--如果pro和xml文件放在源码java包下,也需要编译-->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>