到@Repository annotaion的Spring XML配置类似的样子:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
...
<bean id="translationInterceptor" class="org.springframework.dao.support.PersistenceExceptionTranslationInterceptor" />
<aop:config>
<aop:advisor advice-ref="translationInterceptor" pointcut="within(org.example.spring.dao..*Dao)" />
</aop:config>
...
</beans>
切入点 “内(org.example.spring.dao .. *道)” 适用拦截器在位于包有机类的方法。 example.spring.dao及其子包以“Dao”后缀结尾
将'@Repository'注释应用到dao类而不是服务层bean。对服务层bean使用'@Service' –
我希望使用任何注释来实现相同的WITHOUT,只能使用XML配置。注释工作正常,我只想了解另一种方法,或者确保没有这种方法。在这种情况下,Springs团队声称XML支持的方式与anntations不正确相同。 – alebu