spring配置error2 AOP事务配置缺少包
来源:互联网 发布:apache subversion 编辑:程序博客网 时间:2024/06/18 15:29
写贴上在spring 配置文件applicationContext.xml的事务配置
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:hibernate.cfg.xml" /> <!-- 加载hibernate配置文件 --> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="categoryService" class="com.eshop.service.impl.CategoryServiceImpl"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="advice1" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="*" propagation="SUPPORTS"/> </tx:attributes> </tx:advice> <aop:config> <!-- 配置哪些包的类要切入事务 --> <aop:pointcut id="pointcut1" expression="execution(* com.eshop.service.impl.*.*(..))" /> <aop:advisor advice-ref="advice1" pointcut-ref="pointcut1"/><!-- 连接了上面的advice和上面的pointcut --> </aop:config>
在测试类中运行后出现error
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = "classpath:applicationContext.xml")public class test { @Resource private Date date; @Test public void springIOC(){ System.out.println(date); } @Test public void hibernate() { CategoryService categoryService = new CategoryServiceImpl(); Category category = new Category("男士休闲kk", true); categoryService.save(category);
}
java.lang.IllegalStateException: Failed to load ApplicationContext
测试的错误信息较长 总结 出错信息如下
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.event.internalEventListenerProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': Cannot resolve reference to bean 'pointcut1' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut1': Failed to introspect bean class [org.springframework.aop.aspectj.AspectJExpressionPointcut] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
看到最后一句话 could not find class that it depends on;nested exeception is java**
原因是缺少依赖包aspectjweaver.jar 一般还要导入aopalliance.jar aspectjrt.jar
我所用的时intellij idea 创建工程时的环境是spring 4.3.12 此时spring对于aop编程提供只有2个包
为什么spring实现了aop还需要导入依赖包?
:spring AOP就是用aspectj来实现的,是依赖关系!AspectJ是动态代理的一种实现!而spring默认使用的就是AspectJ来实现的动态代理,spring自己的AOP就是使用AspectJ来实现的,而aspectjweaver.jar这个包是spring集成AspectJ LTW织入器所需包
导入提到的包 error解决
- spring配置error2 AOP事务配置缺少包
- Spring AOP事务配置
- spring aop 事务配置
- spring aop 事务配置
- spring AOP 事务配置
- Spring aop事务配置
- spring的aop事务配置
- spring 事务 aop:pointcut配置
- spring aop事务 propagation配置
- spring aop与事务配置
- spring aop xml配置事务
- spring AOP 的事务配置
- spring aop事务配置,事务回滚
- Spring 2.0 AOP 与事务配置突破
- Spring 2.0 AOP 与事务配置
- Spring 2.0 AOP 与事务配置
- Spring 2.0 AOP 与事务配置
- Spring 2.0 AOP 与事务配置突破
- 加油
- C# WinForm程序退出的方法
- [Struts2 框架学习] 一、Hello,Struts
- Spring框架:启动IOC容器的三种方式
- jar工程install打成包的时候失败
- spring配置error2 AOP事务配置缺少包
- Python中的metaclass
- NYOJ J : CTX学长的找位置游戏
- static、final、static final 用法
- Java 之 Serializable 序列化和反序列化的概念,作用的通俗易懂的解释
- 51nod 1335 子序列翻转
- 设计电路加法实验
- Django复习:视图和模版
- Hi3519V101上移植QT4.8.6