2012年2月28日下午12:46:54 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息:刷新org.springframework.context.support.ClassPathXmlApplicationContext@780024:启动日期[Tue Feb 28 12:46:54 GMT + 05:30 2012];上下文层次结构的根 2012年2月28日下午12:46:54 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息:从类路径资源[newSpringXMLConfig.xml]加载XML bean定义 2012年2月28日下午12:46:55 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息:在org.springframework.beans.factory.support.DefaultListableBeanFactory@ef98ac中预先实例化单例:定义bean [org.springframework.aop.config.internalAutoProxyCreator,tri,cir,shape,LAspect];工厂层级的根 2012年2月28日下午12:46:55 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons INFO:在org.springframework.beans.factory.support.DefaultListableBeanFactory@ef98ac中销毁单例:定义bean [org.springframework.aop.config.internalAutoProxyCreator,tri,cir,shape,LAspect];工厂层级的根 线程“main”中的异常org.springframework.beans.factory.BeanCreationException:在类路径资源[newSpringXMLConfig.xml]中定义名为'tri'的bean时出错:bean的初始化失败;嵌套异常是java.lang.IllegalArgumentException:切入点格式不正确:在字符位置4处期待'名称模式' 得到() ^
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at sam.mainaop.main(mainaop.java:16)
引起:java.lang.IllegalArgumentException:切入点格式不正确:在字符位置4处期待“名称模式” 得到() ^
at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:316)
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:294)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:195)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:181)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:162)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 11 more
Java结果:1 建立成功(总时间:1秒)
和代码:
package sam;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect public class LoggingAspect {
@Before("get()")
public void LoggingAdvice() {
System.out.println("Good Afternoon");
}
@Before("get()")
public void LAdvice() {
System.out.println("Good Morning");
}
@Pointcut("execution(* get*())")
public void get() { }
}
答案 0 :(得分:1)
完整的AspectJ切入点语言支持Spring中不支持的其他切入点指示符。它们是:call,get,set,preinitialization,staticinitialization,initialization,handler,adviceexecution,withincode,cflow,cflowbelow,if,@ this和@withincode。
所以我假设您应该避免Spring Aop中的命名冲突