3

我正在尝试在我的 Maven/Spring (3.2.11.RELEASE) 项目中使用切面。我已经为我的插件配置了这个……</p>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <configuration>
                <complianceLevel>1.6</complianceLevel>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

这是我的方面依赖项……</p>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.8.2</version>
    </dependency>

但是当我运行“mvn clean install”时,我收到了这些警告……</p>

[INFO] --- aspectj-maven-plugin:1.7:compile (default) @ pd ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
    /Users/davea/.m2/repository/org/springframework/spring-aspects/3.2.11.RELEASE/spring-aspects-3.2.11.RELEASE.jar!org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.class:58

[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
    /Users/davea/Dropbox/workspace/pd/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControl.aj:83

[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
    /Users/davea/.m2/repository/org/springframework/spring-aspects/3.2.11.RELEASE/spring-aspects-3.2.11.RELEASE.jar!org/springframework/mock/staticmock/AbstractMethodMockingControl.class:190

[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
    /Users/davea/.m2/repository/org/springframework/spring-aspects/3.2.11.RELEASE/spring-aspects-3.2.11.RELEASE.jar!org/springframework/mock/staticmock/AbstractMethodMockingControl.class:199

如何正确解决依赖关系以便这些警告消失?

编辑: 这是我在 spring WEB-INF/dispatcher-servlet.xml 文件中设置的配置。我正在尝试创建一个私有方法@Transactional ...

<bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf">
    <property name="transactionManager" ref="transactionManager"/>
</bean>

<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
<tx:advice id="txAdvice" >
    <tx:attributes>
        <tx:method name="generateAccess" propagation="REQUIRED"/>
    </tx:attributes>
</tx:advice>
<aop:config>
    <aop:pointcut id="orderServicePC" expression="execution(* org.mainco.subco.myproject.service.OrderService.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="orderServicePC" />
</aop:config>
4

0 回答 0