Spring属性:Spring.config.additional-location非verriden属性值
我使用此命令行在本地启动服务:Spring属性:Spring.config.additional-location非verriden属性值,spring,spring-boot,spring-properties,Spring,Spring Boot,Spring Properties,我使用此命令行在本地启动服务: mvn -pl rep-digital-api clean compile spring-boot:run \ -Dspring-boot.run.arguments=--spring.config.additional-location=front-pre-props.properties preprofile被激活,因为front-pre-props.properties包含spring.profiles.active=pre 在默认的applicati
mvn -pl rep-digital-api clean compile spring-boot:run \
-Dspring-boot.run.arguments=--spring.config.additional-location=front-pre-props.properties
pre
profile被激活,因为front-pre-props.properties
包含spring.profiles.active=pre
在默认的application-dev.properties
中,我设置了以下属性:
api.path-web=web
然而,我需要在本地环境中模拟pre
profile。因此,我需要更改此属性值:
api.path-web=other-path
但是,此属性不会被覆盖
我还测试了将-Dapi.path web=other值设置为mvn命令,但它不起作用
有什么想法吗?如果试图从文件系统添加文件,则需要将属性spring.config.additional location
的值设置为文件:/pathtofile/yourfile.properties
假设您的文件front-pre-props.properties
位于路径/Users/demo/front-pre-props.properties
然后,您可以按以下方式执行run命令:
mvn -pl rep-digital-api -Dspring.config.additional-location=“file:/Users/demo/front-pre-props.properties” clean compile
spring-boot:run
您的文件front-pre-props.properties位于哪里?如果它在类路径中,即在参考资料下,则不需要定义spring.config.additional-location。默认情况下,spring boot会选择以下位置:默认搜索位置=“classpath:/,classpath:/config/,文件:./,文件:./config/”;它位于我的项目之外的我的文件系统中。在您的情况下,您需要将位置指定为:file:./absolutepath/front-pre-props.properties您能提供更多帮助代码吗?我的意思是,我如何指定这个值?请检查我的答案