JAR包resources中有两个目录用于放properties
develop(开发环境)、product(生产环境),包含文件default.properties、其他.properties
某项目依赖该JAR包
resources结构与JAR包相同,并包含local.properties、其他properties
spring.xml使用下面方式 根据jdk中设置的-Denvironment=product判断是否是生产环境,来切换properties
<context:property-placeholder location="classpath*:#{systemProperties['environment'] ?: 'develop'}/*.properties" file-encoding="UTF-8" ignore-resource-not-found="true" ignore-unresolvable="true" local-override="false"></context:property-placeholder>
上面的配置无法覆盖(因为local.properties先于default.properties读取)。