Spring配合类使用@PropertySource和@Value注入值失败问题
今天在使用Spring整合Mybatis时,使用配置类代替xml配置,需要读取db.properties中的值来配置数据库连接池,发现不管配置之后driver、url等都是null;后来看到一篇博客给出了解决方案和原因,原因因为设计到SpringIOC的源码,现在还不太明白,下面给出解决措施:想知道原理可以参考这篇文章:http://yeming.me/2017/04/16/springValueAnnotation/
原来的配置类:
@ComponentScan(basePackages = {"da
原创
2020-08-10 20:07:42 ·
1894 阅读 ·
0 评论