spring 4 mvc aop not work -
pom this
<!-- spring mvc <spring-framework.version>4.2.2.release</spring-framework.version> --> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-context</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-webmvc</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-context-support</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-aop</artifactid> <version>${spring-framework.version}</version> </dependency> <!-- aspectj <aspectj.version>1.8.6</aspectj.version> --> <dependency> <groupid>org.aspectj</groupid> <artifactid>aspectjrt</artifactid> <version>${aspectj.version}</version> </dependency> <dependency> <groupid>org.aspectj</groupid> <artifactid>aspectjtools</artifactid> <version>${aspectj.version}</version> </dependency> <dependency> <groupid>org.aspectj</groupid> <artifactid>aspectjweaver</artifactid> <version>${aspectj.version}</version> </dependency>
aspect this
@aspect public class restfulaspect { @before("methodpointcut()") public void beforeimpl() { system.out.println(" before done "); } @pointcut("execution(* com.smart.testspring.repository.bookrespository.selectall(..))") public void methodpointcut() { system.out.println(" pointcut "); }}
applicationcontext
<aop:aspectj-autoproxy /> <bean id="bookbean" class="com.smart.testspring.repository.bookrespository" /> <bean id="aspectbean" class="com.smart.testspring.aop.restfulaspect" />
and try <!--<mvc:annotation-driven />-->
can't find controller.so did not add <mvc:annotation-driven />
.
above project, aspect don't have work, helped me check out problems.
that mvc container application child container, aop configuration moved mvc-config configuration file, it's worked.
Comments
Post a Comment