Spring AOP 報錯org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path resource..........


完整報錯如下:


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beforeAdvice' 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': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 10
execution()

出現了一種<aop:config>標簽與bean無法共存的現象,一開始以為是aspectj 包的版本問題,可修改來修改去,還是報錯。

解決方案:后來發現,還是因為excution()內的表達式寫錯了,修改后運行成功。

    <aop:config>
        <aop:aspect id="beforeAspect" ref="beforeAdvice">
            <aop:before method="methodBefore" pointcut="execution(* com.ph.service..*.*(..))"/>
        </aop:aspect>
    </aop:config>

如果排除了版本不匹配、注解沒寫等問題后,還是報錯,就要考慮是不是execution表達式寫錯了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource 使用security報錯:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.datasource.DataSourceTransactionManager#0' defined in class path resource [spring-mybat Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fundService': Injection of resource dependencies failed; 錯誤/異常:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/beans_common.xml]...的解決方法 spring測試出錯:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0': SpringBoot 報 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapImportSelectorConfiguration': Initialization of bean failed; Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name spring整合hibernate無法創建Bean----org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentDao' defined in file
 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM