【发布时间】:2017-02-15 04:11:31
【问题描述】:
无法使用Aspectj 编译我的项目。 Apache CXF 存在一个问题,ResourceContext.getResource(SomeClass.class) 创建了一个简单的对象,而不是 Spring 管理的对象。所以我想用编织和@Configurable来渡过这个难关。我让它在我的测试 Spring Boot 应用程序中工作(如果需要,我可以在 Github 上提供一个链接),使用@Configurable 本身和@EnableSpringConfigured 进行以下设置:
这是我的 pom.xml 的快照(Spring 版本是 4.3.3.RELEASE):
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
和aspectj-maven-plugin 插件配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<complianceLevel>1.8</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
但是,当我尝试在我公司的实际项目中应用上述配置时,我收到了这个奇怪的错误:
[ERROR] *path to the java file being weaving* can't determine annotations of missing type javax.transaction.Transactional
[ERROR] when weaving type *the full java class name*
[ERROR] when weaving classes
[ERROR] when weaving
[ERROR] when batch building BuildConfig[null] #Files=27 AopXmls=#0
[ERROR] [Xlint:cantFindType]
[ERROR] error at (no source information available)
我的测试项目没有使用@Transactional,但真正的项目使用了。所以我尝试添加 spring-tx 和 persistence-api 依赖项,但没有任何效果。最后一点:该项目在我第二次运行mvn install 时构建成功,但每次运行mvn clean install 时均不成功。
非常感谢任何帮助,因为我真的被这个错误困住了。
【问题讨论】:
标签: spring maven spring-aop spring-transactions compile-time-weaving