今天打完项目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>
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐