mak*_*aks 6 spring compile-time-weaving maven
我想为标记有@Configurable注释的类配置编译时编织,以便能够将spring依赖项注入到使用newoperator 实例化的类中.我不想使用加载时编织,因为我没有访问应用程序服务器的运行脚本,所以我无法修改它.此外,我希望能够在测试中使用此类,我的意思是从IDE运行测试用例.我只发现了有关网络上的加载时间编织和弹簧参考的信息,而没有关于编译时编织配置的信息.
PS.我和maven一起使用spring
你的 pom 中类似的东西应该可以工作......
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>compile</id>
<configuration>
<source>${source}</source>
<target>${target}</target>
<verbose>true</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<configuration>
<source>${source}</source>
<target>${target}</target>
<verbose>false</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- Ensure aspectj tools version used by compiler is the same version used as dependency. Avoids warning -->
<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>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后确保你的类路径上有 spring 方面。
对于 Eclipse 中的方面 - 安装AJDT
| 归档时间: |
|
| 查看次数: |
3489 次 |
| 最近记录: |