spring boot @value 取不到.properties的值_Java_Jagger的博客-CSDN博客

最近我们组在为别的组提供api接口,需要通过@value取到properties里配置的超时时间,结果怎么设置都取不到,而通过@ConditionalOnProperty或者@ConfigurationProperties,都可以成功取到,最后在坚持不懈的努力下,找到了原因,因为那个项目用到了shiro,而shiro有个配置和@value正好冲突了。

@Bean
public  LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
    return new LifecycleBeanPostProcessor();
}

最后通过自定义的properties,然后通过@ConfigurationProperties(prefix = "prefix", locations = "classpath:config.properties")加载进来,如果是yml的话参照spring官网的https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-yaml-shortcomings

最后

至于为什么会冲突我还没时间研究。。先埋个坑,以后在填。


Original url: Access
Created at: 2020-03-13 12:04:30
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论