Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aspectJ' defined in class path resource [ApplicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is
错误信息:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aspectJ' defined in class path resource [ApplicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character position 30
extucion(*com.demo.service.*.*(..))
^
ApplicationContext.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: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
">
<bean id="aspectJ" class="com.demo.aspect.AspectJ"></bean>
<bean id="aspectService" class="com.demo.service.AspectService"></bean>
<!-- 切面的配置 -->
<aop:config>
<aop:aspect id="aspectJAOP" ref="aspectJ">
<!-- 切入点的配置 -->
<aop:pointcut expression="extucion(*com.demo.service.*.*(..))" id="aspectPointcut"/>
<!-- beforeAdvice的声明 -->
<aop:before method="before" pointcut-ref="aspectPointcut"/>
</aop:aspect>
</aop:config>
</beans>
AspectJ.java
package com.demo.aspect;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class AspectJ {
public void before(){
System.out.println("Before");
}
}
AspectService.java
package com.demo.service;
public class AspectService {
public void service(){
System.out.println("AspectService service");
}
}
SpringText.java
package com.demo.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.demo.aspect.AspectJ;
import com.demo.service.AspectService;
public class SpringTest {
public static void main(String[] args){
ApplicationContext ctx=new ClassPathXmlApplicationContext("ApplicationContext.xml");
AspectService service= (AspectService) ctx.getBean("aspectService");
service.service();
}
}