2017-07-18 4 views
1

これはapplicationContext.xmlを AOPの一部です:春AOPの表現

<bean id="logHandler" class="demo.anderson.aop.LogHandler"></bean> 
<aop:config> 
    <aop:aspect id="log" ref="logHandler">  
     <aop:pointcut id="addLog" expression="execution(* demo.anderson.controller.StudentController.*(..)) || execution(* demo.anderson.controller.ScoreController.*(..))" /> 
     <aop:before method="beforeLog" pointcut-ref="addLog" /> 
     <aop:after method="afterLog" pointcut-ref="addLog" /> 
    </aop:aspect> 
</aop:config> 

それが働いています!

しかし、私はAOPを設定します。このようなポイントカット:

<aop:pointcut id="addLog" expression="execution(* demo.anderson.controller.*.*(..))" /> 

それが壊れています:06:

18 - 7月 - 2017年11 39.416嚴重[HTTP-NIO-8090-exec- 71] org.apache.catalina.core.StandardContext.listenerStart例外 クラス org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationExceptionのインスタンスリスナーにコンテキスト初期化イベント送信:Eをエラー 名前が のBeanの作成 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Beanの初期化が失敗しました。ネストされた例外は です。java.lang.IllegalStateException:予想される生タイプの形式 org.springframework.web.servlet.handler.AbstractHandlerMethodMapping $一致 .................... .........................................原因: :java.lang.IllegalStateException :予想される生タイプの形式 org.springframework.web.servlet.handler.AbstractHandlerMethodMapping $一致 ............................. ................................

18-Jul-2017 11:06:39.434資格[http- nio-8090-exec-71] org.apache.catalina.core.ApplicationContext.log Springルートのクローズ WebApplicationContext

誰かが私にその理由を教えてもらえますか?正しい構成は何ですか?

答えて

0
<aop:pointcut id="addLog" expression="execution(* demo.anderson.controller..*.*(..))" /> 

春のdocsから参照。

https://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html

サービスパッケージまたはサブパッケージに定義された任意の方法の実行:(。* com.xyz.service .. **(..))

実行

+0

答えはThxですが、コントローラパッケージにサブパッケージはありません。 他のアドバイスはありますか? –