无法使我的项目使用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
。
非常感谢任何帮助,因为我真的被这个错误困住了。