Nyx*_*xMC 12 java aspectj maven lombok
我试图将Lombok与AspectJ和Maven结合使用.所以有什么问题?当我使用AspectJ Maven插件(www.mojohaus.org/aspectj-maven-plugin/)时,它会获取源代码并编译它们并忽略Lombok所做的更改.我按照本教程编写了这个代码,AspectJ可以正常工作,但Lombok因此消息而死:
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
Run Code Online (Sandbox Code Playgroud)
那么,有没有人知道如何让Lombok与AspectJ结合使用?
[编辑]它工作!现在,当我将项目打包到一个胖罐子时似乎工作.但它仍然无法与maven:test和IntelliJ一起使用.如果有人对此有所帮助,我会很高兴.
最好的祝福!
小智 7
使用ajc处理类。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<complianceLevel>8</complianceLevel>
<source>8</source>
<target>8</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>UTF-8</encoding>
<!-- IMPORTANT-->
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<forceAjcCompile>true</forceAjcCompile>
<sources/>
<!-- IMPORTANT-->
<aspectLibraries>
<aspectLibrary>
<groupId>you.own.aspect.libary</groupId>
<artifactId>your-library</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>process-classes</phase>
<goals>
<!-- use this goal to weave all your main classes -->
<goal>compile</goal>
</goals>
<configuration>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>process-test-classes</phase>
<goals>
<!-- use this goal to weave all your test classes -->
<goal>test-compile</goal>
</goals>
<configuration>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/test-classes</weaveDirectory>
</weaveDirectories>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
使用delombok生成正常的源代码。然后按照未使用 Lombok 时的方式继续操作。
将带有 Lombok 注释的代码存储在 main/src/lombok 中(例如),然后让 delombok 插件将这些注释转换为普通代码并放入目录 /delomboked(例如)。
| 归档时间: |
|
| 查看次数: |
6236 次 |
| 最近记录: |