初学spring配置出错 跟帖有分

时间:2022-06-08 20:32:35
applicationContext:
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">


<aop:aspectj-autoproxy></aop:aspectj-autoproxy>


<bean id="interceptor" class="com.dcj.aop.Interceptor"/>


<aop:config>
<aop:pointcut expression="public * com.dcj.service..*.deleteUser(..)" id="logPointcut" />
<aop:aspect id="logAspect" ref="interceptor">
<aop:before method="before" pointcut-ref="logPointcut" />
</aop:aspect>

</aop:config>

</beans>

编译出错  Class 'org.springframework.aop.aspectj.AspectJExpressionPointcut' not found
在aop:pointcut aop:before 这两行 
jar包为 spring3.0 和aspectjweaver 和 aspectjrt

19 个解决方案

#1


跟帖^_^

#2


package com.dcj.aop;

import org.aspectj.lang.ProceedingJoinPoint;

public class Interceptor {
public void before() {
System.out.println("method start ---------");
}

public void after() {
System.out.println("method end ---------");
}

public Object around(ProceedingJoinPoint pjp) throws Throwable {
before();
Object retVal = pjp.proceed();
after();
return retVal;
}
}
这是切面类 ,网上说如果传参数会出错 ,我这方法也没传参数啊。。

#3


引用楼主 superdcj 的回复:
applicationContext:

XML code
<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   ……


少包了吧

#4


引用 3 楼 shanxmxj 的回复:
引用楼主 superdcj 的回复:
applicationContext:

XML code
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-in……
那少什么包了呢。。

#5


aspectj.jar

#6


架包Spring-aop.jar的问题,你看是少架包,还是冲突的原因,Struts1.0,Srping2.5,hibernate3.2三个框架搭建起来完整架包数位84个,你自己看看...

#7


看下spring-aspects.jar包有没有 

#8


少这个包吧
spring-aspects.jar

#9


刚才看了代码确定了 

spring-2.5.6.jar  里面有这个类

应该是你的核心包版本比较低,你换成spring-2.5.6.jar 

#10


顶顶 求分

#11


我用的spring3.0 不是那个问题啊。。要不大家留个qq..方便交流

#12


spring包的版本较低,下载个新版本的试试。

#13


不是版本低的问题。。应该是冲突了

#14


引用 5 楼 shanxmxj 的回复:
aspectj.jar

+1

#15


spring 不太懂哦

#16


引用 14 楼 jio89125099 的回复:
引用 5 楼 shanxmxj 的回复:
aspectj.jar

+1

+1

#17


该回复于2010-12-02 11:28:52被版主删除

#18


应该就是spring的配置冲突

#19


该回复于2010-12-02 12:46:28被版主删除

#1


跟帖^_^

#2


package com.dcj.aop;

import org.aspectj.lang.ProceedingJoinPoint;

public class Interceptor {
public void before() {
System.out.println("method start ---------");
}

public void after() {
System.out.println("method end ---------");
}

public Object around(ProceedingJoinPoint pjp) throws Throwable {
before();
Object retVal = pjp.proceed();
after();
return retVal;
}
}
这是切面类 ,网上说如果传参数会出错 ,我这方法也没传参数啊。。

#3


引用楼主 superdcj 的回复:
applicationContext:

XML code
<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   ……


少包了吧

#4


引用 3 楼 shanxmxj 的回复:
引用楼主 superdcj 的回复:
applicationContext:

XML code
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-in……
那少什么包了呢。。

#5


aspectj.jar

#6


架包Spring-aop.jar的问题,你看是少架包,还是冲突的原因,Struts1.0,Srping2.5,hibernate3.2三个框架搭建起来完整架包数位84个,你自己看看...

#7


看下spring-aspects.jar包有没有 

#8


少这个包吧
spring-aspects.jar

#9


刚才看了代码确定了 

spring-2.5.6.jar  里面有这个类

应该是你的核心包版本比较低,你换成spring-2.5.6.jar 

#10


顶顶 求分

#11


我用的spring3.0 不是那个问题啊。。要不大家留个qq..方便交流

#12


spring包的版本较低,下载个新版本的试试。

#13


不是版本低的问题。。应该是冲突了

#14


引用 5 楼 shanxmxj 的回复:
aspectj.jar

+1

#15


spring 不太懂哦

#16


引用 14 楼 jio89125099 的回复:
引用 5 楼 shanxmxj 的回复:
aspectj.jar

+1

+1

#17


该回复于2010-12-02 11:28:52被版主删除

#18


应该就是spring的配置冲突

#19


该回复于2010-12-02 12:46:28被版主删除

#20