【问题标题】:maven aspectJ plugin compile errormaven aspectJ插件编译错误
【发布时间】:2014-08-01 20:10:14
【问题描述】:

我在一个 maven 项目中使用 maven-aspectJ 插件。我想编织 cucumber-java 库。当我运行 maven 时,我不断得到

[ERROR] Failed to execute goal
org.codehaus.mojo:aspectj-maven-plugin:1.5:compile (default)
on project junitsampler:
    The artifact info.cukes:cucumber-java referenced in aspectj plugin as
    dependencies and/or directories to weave, is not found the project
    dependencies -> [Help 1]

我的插件配置如下:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.5</version>
    <!-- <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> 
        <version>1.7</version> <scope>system</scope> <systemPath>${tools-jar}</systemPath> 
        </dependency> </dependencies> -->
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>       <!-- use this goal to weave all your main classes -->
                <goal>test-compile</goal>  <!-- use this goal to weave all your test classes -->
            </goals>
        </execution>
    </executions>
    <configuration>
        <source>1.7</source>
        <complianceLevel>1.7</complianceLevel>
        <verbose>true</verbose>
        <showWeaveInfo>true</showWeaveInfo>
        <target>1.7</target>
        <forceAjcCompile>true</forceAjcCompile>
        <weaveDirectories>
            <weaveDirectory>C:/Users/shenv/workspace/junitsampler/target/classes/cucumber</weaveDirectory>
        </weaveDirectories>

        <!-- <weaveDependencies> <weaveDependency> <groupId>com.autodesk.dm.wipdata.jmeter</groupId> 
            <artifactId>junitsampler</artifactId> </weaveDependency> <weaveDependency> 
            <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> </weaveDependency> -->
        <weaveDependencies>
            <weaveDependency>
                <groupId>info.cukes</groupId>
                <artifactId>cucumber-java</artifactId>
            </weaveDependency>
        </weaveDependencies>
    </configuration>
</plugin>

我检查了 pom.xml 并且依赖项在那里。我在这里错过了什么?

【问题讨论】:

    标签: java maven aspectj aspectj-maven-plugin


    【解决方案1】:

    您的&lt;weaveDependency&gt; 应该引用已在您的pom.xml 中定义的依赖项。你在&lt;dependencies&gt; 下做过吗?像这样:

    <project>
        <dependencies>
            <dependency>
                <groupId>info.cukes</groupId>
                <artifactId>cucumber-java</artifactId>
                <version>1.1.8</version>
            </dependency>
            <!-- (...) -->
        </dependencies>
        <!-- (...) -->
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <version>1.5</version>
                    <!-- (...) -->
                    <configuration>
                        <!-- (...) -->
                        <weaveDependencies>
                            <weaveDependency>
                                <groupId>info.cukes</groupId>
                                <artifactId>cucumber-java</artifactId>
                            </weaveDependency>
                        </weaveDependencies>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    

    另见AspectJ Maven plugin documentation

    【讨论】:

    • 是的,我做到了。我确认存在依赖关系。
    • 然后发布完整的 POM,并在必要时发布一些最小的示例代码以清楚地重现问题。
    猜你喜欢
    • 2017-04-24
    • 2015-01-07
    • 2016-10-28
    • 1970-01-01
    • 1970-01-01
    • 2018-03-03
    • 2011-12-20
    • 2021-11-27
    • 1970-01-01
    相关资源
    最近更新 更多