【发布时间】:2019-12-23 10:21:53
【问题描述】:
我正在使用这个命令行来在本地启动我的服务:
mvn -pl rep-digital-api clean compile spring-boot:run \
-Dspring-boot.run.arguments=--spring.config.additional-location=front-pre-props.properties
pre 配置文件已激活,因为 front-pre-props.properties 包含 spring.profiles.active=pre。
进入默认application-dev.properties我已经设置了这个属性:
api.path-web=web
不过,我需要将pre 配置文件模拟到我的本地环境中。所以我需要改变这个属性值:
api.path-web=other-path
不过,此属性并未被覆盖。
我还测试了将-Dapi.path-web=other-value 设置为 mvn 命令,但它不起作用...
有什么想法吗?
【问题讨论】:
-
您的文件 front-pre-props.properties 位于何处?如果在classpath下,也就是在resources下,那么就不需要定义spring.config.additional-location。默认情况下,spring-boot 会选择这些位置:DEFAULT_SEARCH_LOCATIONS = "classpath:/,classpath:/config/,file:./,file:./config/";
-
它在我的项目之外的文件系统中。
-
在您的情况下,您需要将位置指定为:file:./absolutepath/front-pre-props.properties
-
您能提供更多帮助代码吗?我的意思是,我该如何指定这个值?
-
请查看我的回答
标签: spring spring-boot spring-properties