java - spring-boot 和 ./config 目录

标签 java spring spring-boot

我不再确定 Spring-boot 到底如何处理环境、属性文件和配置位置。

用例

下面是我的 spring-boot 应用程序的结果 docker 容器

Docker 容器

 /
 |- spring-boot-app.jar
 |- /config/
 |--|- application.properties
 |--|- logback-spring.xml

我还使用环境变量

问题

Spring-boot 不会读取 logback-spring.xml。 为了做到这一点,我必须添加 LOGGING_CONFIG=config/logback-spring.xml

Spring-boot 不应该在这个目录下自动查找 logback-spring.xml 吗?

谢谢

最佳答案

在 Spring 文档 (https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html) 中,它说:

The various logging systems can be activated by including the appropriate libraries on the classpath, and further customized by providing a suitable configuration file in the root of the classpath, or in a location specified by the Spring Environment property logging.config.

因此,如果您将文件直接放在 spring-boot-app.jar 下,它应该无需配置 logging.config 即可工作。

关于java - spring-boot 和 ./config 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46649085/

相关文章:

java - 尝试在空对象引用上调用虚拟方法 'int java.lang.String.length()'

java - 在接口(interface)级别解耦两个类是什么意思?

java - 模拟 bean 的依赖项的 NoSuchBeanDefinitionException

java - 如何解决Spring Boot应用程序中的CORS问题?

java - 我无法使用 Java Spring Boot 和 Angular 7 在远程服务器(Apache2)上上传文件。它在本地主机上运行良好

java - 批处理字符串包含操作优化?

java - 小行星类游戏中的正确运动

java - Android 应用程序上的多个传感器

java - Springboot API 将请求放入队列?

Spring 启动: Secured RESTful API using Spring Social and Spring Security