1.applicationContext.xml中AspectJ 配置的内容:
2.注入的实现方式:
我的项目中使用了XXService接口。XXServiceImpl为XXService接口的实现类。XXServiceImpl中调用了XXDao接口进行对数据库的操作。XXDaoImpl为XXDao接口的实现类。
其中XXServiceImpl中使用@Service注入至程序,使用@Autowired将Dao注入至Service。XXDaoImpl中使用@Repository注入至程序。
XXService代码:
XXServiceImpl代码:
XXDao代码:
XXDaoImpl代码:
3.Filter中获取bean
通过2中的代码,在Filter中如果想获取service的话,只可以获得XXServiceImpl的bean,即只能获得service的实现类bean。
注意:在通过context.getBean()时,参数的bean名称为类名,但类名的第一个字母要小写。
代码: