Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring属性:Spring.config.additional-location非verriden属性值_Spring_Spring Boot_Spring Properties - Fatal编程技术网

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您能提供更多帮助代码吗?我的意思是,我如何指定这个值?请检查我的答案