首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Boot无法与dependent application.properties一起使用

Spring Boot无法与dependent application.properties一起使用
EN

Stack Overflow用户
提问于 2020-08-08 00:30:18
回答 1查看 127关注 0票数 1

我正在使用Spring Boot2.2.9.RELEASE。我有主应用程序和一些普通的starter (它只使用spring-actuator功能),在它的some-starter/src/main/resources/application.properties文件中有一些属性:

代码语言:javascript
复制
management.server.port=9000
management.server.ssl.enabled=false
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=health

我已经将starter导入到我的主应用程序中,并且我相信healthcheck端点应该与端口9000和路径/health (smth类似于那个localhost:9000/health)一起工作。

然而,如果我的主应用程序main-app/src/main/resources/application.properties中有相同的属性,它就会起作用。

Spring Boot中的属性重写有问题吗?我是否应该通过maven-resources-plugin之类的工具配置我的资源

EN

回答 1

Stack Overflow用户

发布于 2020-08-08 02:33:25

当从类路径加载application.properties时,类路径上的第一个将被加载,类路径上的任何其他are都将被忽略。在本例中,main-app/src/main/resources/application.properties中的文件将出现在some-starter的jar中的application.properties之前的类路径中。

顾名思义,application.properties旨在配置您的应用程序,不应该在starter中使用它。您可以在应用程序中配置所有属性,也可以更新入门程序以包含通过spring.factories注册的EnvironmentPostProcessor,并将一些默认属性添加到Environment中。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63305836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档