【问题标题】:How to make AspectJ and Lombok co-work with maven?如何让 AspectJ 和 Lombok 与 maven 协同工作?
【发布时间】:2017-06-28 14:20:07
【问题描述】:

我试过这个链接的方法:https://palesz.wordpress.com/2011/12/03/howto-maven-lombok-and-aspectj-together/

但错误显示:

[ERROR] no sources specified
    <unknown source file>:<no line information>

[ERROR] AspectJ Compiler 1.8.9

    Usage: <options> <source file | @argfile>..

我是这样使用插件的:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.10</version>
    <configuration>
        <verbose>true</verbose>
        <showWeaveInfo />
        <forceAjcCompile>true</forceAjcCompile>
        <sources />
        <complianceLevel>1.8</complianceLevel>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
    <executions>
        <execution>
            <phase>process-classes</phase>
            <goals>
                <goal>compile</goal>
                <goal>test-compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

而相关的依赖有:

<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.8.10</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.8.10</version>
</dependency>

【问题讨论】:

    标签: java maven aspectj lombok


    【解决方案1】:

    我按照相同的帖子进行操作,但你忘记了一件事(我也忘记了)。

    您需要将 weaveDirectories 添加到配置中:

    <weaveDirectories>
      <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
    </weaveDirectories>
    

    这个原因很明显,因为sources标签是空的,aspectj-maven-plugin需要一些东西来处理。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2014-11-12
      • 2017-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-17
      • 2020-01-13
      相关资源
      最近更新 更多