springboot 继承shiro 使用redis缓存 @Value 标签无效 无法获取zhi

来源:互联网 发布:js utc转换 gmt 8000 编辑:程序博客网 时间:2024/05/21 09:19

在开发中使用了shiro作为权限管理,之前也没管shiro的缓存问题,就是会有点打印日志说没缓存,今天抽时间想加一下redis的缓存,一查还挺简单,但是在使用@Valle获取redis配置的时候发现无法获取:

    @Value("${redis.host}")

    private String host;
    @Value("${redis.port}")
    private int port;
    @Value("${redis.pass}")
    private String password;

然后发现两种方案 参考文档 参考文档中提到的stackoverflow

注释掉

@Bean(name = "lifecycleBeanPostProcessor")public  LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {    return new LifecycleBeanPostProcessor();}
或者改成

@Bean(name = "lifecycleBeanPostProcessor")public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {    return new LifecycleBeanPostProcessor();}
就能正常获取数据了

推荐使用第二种

原创粉丝点击