普通类获取spring的bean对象

普通类获取spring的bean对象

解决方法:

假如我想在普通类中获取CustomJdbcTemplate对象

ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

if (attributes == null) {

throw new RuntimeException("非web请求,非法调用!");

} else {

http://www.yayihouse.com/yayishuwu/chapter/2019

}

猜你喜欢

转载自blog.csdn.net/qq_30908729/article/details/95065082