小编MUH*_*HAN的帖子

自动连接的依赖项未在Spring MVC中的Aspect中注入

我无法@Autowire在Aspect中使用服务层实例.在Aspect中,对@Autowiredbean 的引用是NULL并且它会抛出NullPointerException.任何帮助都感激不尽.我想,我搞砸了配置.

以下是我的servlet-context.xml:

<!-- Activates various annotations to be detected in bean classes -->
<context:annotation-config />
<context:spring-configured />       

<!-- Scans the classpath of this application for @Components to deploy as beans -->
<context:component-scan base-package="xx.yy" />

<!--  an @AspectJ aspect will be interpreted as an aspect by Spring AOP and beans in the context will be advised accordingly -->
<aop:aspectj-autoproxy />

<beans:bean id="loggingAspect" class="xx.yy.aop.aspects.LoggingAspect" />
<beans:bean id="authenticationAspect" class="xx.yy.aop.aspects.AuthenticationAspect" />

<!-- Enables the Spring …
Run Code Online (Sandbox Code Playgroud)

aop aspectj spring-mvc spring-aop

10
推荐指数
1
解决办法
8974
查看次数

标签 统计

aop ×1

aspectj ×1

spring-aop ×1

spring-mvc ×1