龙目岛和AspectJ [英] Lombok and AspectJ

查看:191
本文介绍了龙目岛和AspectJ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Lombok与AspectJ和Maven结合使用. 所以有什么问题? 当我使用AspectJ Maven插件(www.mojohaus.org/aspectj-maven-plugin/)时,它将获取源代码并对其进行编译,而忽略了Lombok所做的更改.我遵循了本教程,使用此代码,AspectJ可以工作,但是Lombok死于此消息:

Im trying to use Lombok in combination with AspectJ and Maven. So, what's the problem? When i use the AspectJ Maven Plugin (www.mojohaus.org/aspectj-maven-plugin/), it takes the sources and compiles them and ignores changes made by Lombok. I followed this tutorial and came up with this code and AspectJ works, but Lombok dies with this message:

[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

那么,有人知道如何将Lombok与AspectJ结合使用吗?

So, does anyone know how to get Lombok in combination with AspectJ working?

可行!现在,当我将项目打包到一个胖子罐中时,它似乎可以工作. 但是它仍然不适用于maven:test和IntelliJ .如果有人可以解决此问题,我将很高兴.

IT WORKS! Now, it seems to work when i package the project to a fat jar. But it still does not work with maven:test and IntelliJ. I'd be happy if anyone had a fix for this.

最诚挚的问候!

推荐答案

使用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>

这篇关于龙目岛和AspectJ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆