【发布时间】:2021-12-10 21:58:40
【问题描述】:
我的 spring 应用程序是通过 WebApplicationInitializer 启动的。
public class WebAppInitializer implements WebApplicationInitializer
{
@Override
public void onStartup(ServletContext servletContext) throws ServletException
{
....
}
}
我有配置类
@Configuration
@PropertySources({
@PropertySource(value = "classpath:application.properties"))
})
public class MainConfig
{
....
}
在 application.properties 文件中,我尝试覆盖 spring 和 logging 属性
logging.level.com.app=DEBUG
logging.level.org.springframework.web=DEBUG
文件application.properties在目录src/main/resources中
但它没有任何作用——意味着没有属性被应用到spring或日志系统
【问题讨论】:
-
没有效果是什么意思?你期待什么?
-
有了您的
@Configuration,application.properties就成为了财产来源。您还没有向我们展示您使用这些属性的任何地方。 -
目前还不清楚你在问什么。为什么您希望您的财产来源适用于“日志系统”??
-
为什么不呢?在所有的例子中,这都是写的。另外,弹簧本身的属性也没有应用
-
什么例子? 弹簧本身的属性是什么意思?
标签: java spring properties property-files