![](/img/trans.png)
[英]Spring boot MessageSource not working in application.properties
[英]Spring Boot not working with dependent application.properties
我正在使用 Spring Boot 2.2.9.RELEASE。 我在其some-starter/src/main/resources/application.properties
文件中有主应用程序和一些简单的启动器(仅使用spring-actuator
功能)和一些属性:
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
我已经将启动器导入到我的主应用程序中,并且我相信 healthcheck 端点应该与端口9000
和路径/health
一起使用(就像localhost:9000/health
一样)。
但事实并非如此。 但是,它适用于我的主应用程序main-app/src/main/resources/application.properties
中的相同属性。
Spring Boot 中的属性覆盖是否有问题? 我应该通过maven-resources-plugin
类的东西配置我的资源吗?
当从类路径加载application.properties
时,将加载类路径上的第一个,而忽略类路径上的任何其他属性。 在您的情况下, main-app/src/main/resources/application.properties
中的文件将出现在some-starter
的 jar 中的application.properties
之前的类路径中。
顾名思义, application.properties
旨在配置您的应用程序,不应在启动程序中使用它。 您应该配置应用程序中的所有属性,或者您可以更新启动器以包含通过spring.factories
注册的EnvironmentPostProcessor
并向Environment
添加一些默认属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.