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 'webSocketHandlerMapping' defined in class path resource 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 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' 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 新建項目用flyway數據遷移時報錯找不到flyway org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource idea 啟動springboot項目時報錯:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM