一般配置文件都是根据profile进行区分
但通过maven编译后,配置文件所存放的路径是不需要profile的,直接打在classPath下就可以
所以就可以通过maven打包的方式,把配置文件直接打包到classPath下。
有一种方式为在根Pom节点下的 <profiles>下新增配置
<profile> <id>local</id> <build> <resources> <resource> <directory>${profiles.dir}/local</directory> </resource> </resources> </build> </profile>
<properties> <profiles.dir>src/main/profiles</profiles.dir> </properties>
最外层根目录需要加上,不然local下面的文件会完全覆盖resources下面的文件
<build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>
通过这种方式把local下配置文件直接打到classPath下
效果如下 原resources下没有uncc配置文件,通过指定目录可直接打到classPath下