在配置shiro时出现一个问题,@Value找不到值,经过多方求教,找到两种解决方案:
@Configuration
public class ShiroConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.password}")
private String password;
@Value("${spring.redis.port}")
private int port;
@Value("${spring.redis.timeout}")
private int timeout;
方法发1. 去掉LifecycleBeanPostProcessor配置。
@Bean
public LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
}
方法发2. LifecycleBeanPostProcessor配置static。
@Bean
public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
}
使用哪个方法根据自己业务来选择,建议使用方法2。
欢迎访问我的个人博客:www.wangzhy.com.cn