< pluginManagement>标签会导致“找不到符号"在Maven2上 [英] <pluginManagement> tag causes "cannot find symbol" on Maven2

查看:68
本文介绍了< pluginManagement>标签会导致“找不到符号"在Maven2上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pom.xml文件,该文件具有以下结构:

I have a pom.xml file that has the following structure:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>someParentGroupId</groupId>
        <artifactId>someParentArtifactId</artifactId>
        <version>someParentVersionId</version>
    </parent>
    <artifactId>...</artifactId>
    <name>...</name>
    <packaging>war</packaging>
    <properties>
        <aspectj.version>1.6.12</aspectj.version>
        <roo.version>1.2.2.RELEASE</roo.version>
        <spring.version>3.1.0.RELEASE</spring.version>
        <camel.version>2.10-SNAPSHOT</camel.version>
        <spring-security.version>3.1.0.RELEASE</spring-security.version>
    </properties>

    <repositories>
        <repository>
            <id>someRepoId</id>
            <name>someRepoName</name>
            <url>someRepoURL</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>somePluginRepoId</id>
            <name>somePluginRepoName</name>
            <url>somePluginRepoURL</url>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>
        <dependency>
            <groupId>someDependencyGroupId</groupId>
            <artifactId>someDependencyArtifactId</artifactId>
            <version>someDependencyVersion</version>
            <scope>someDependencyScope</scope>
        </dependency>
    </dependencies>
    <build>

    <!-- <pluginManagement> -->
        <plugins>
            <plugin>
                <groupId>somePluginGroupId</groupId>
                <artifactId>somePluginArtifactId</artifactId>
                <version>somePluginVersionId</version>
            </plugin>

        </plugins>
    <!-- </pluginManagement> -->
    </build>
</project>

当标记被注释时,我可以毫无问题地运行mvn install,但是Eclipse在pom.xml中出错了!

When I have the tag commented, I can run mvn install without problems, but Eclipse goes coconuts with errors in my pom.xml!

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.2:compile (execution: default, phase: process-sources)

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.2:test-compile (execution: default, phase: process-test-sources)

但是,如果我在所有Eclipse项目中添加了没有错误的标记,但是我无法运行mvn install!这是运行mvn -e install

If however, I add the tag I have no errors in any of my Eclipse projects, but I cannot run mvn install ! Here is part of the output from running mvn -e install

/home/pedro/dss-project/dss/dss-server/src/main/java/net/jnd/thesis/domain/SessionCondition.java:[79,9] cannot find symbol
symbol  : method getValue()
location: class net.jnd.thesis.domain.SessionCondition
/home/pedro/dss-project/dss/dss-server/src/main/java/net/jnd/thesis/web/AdminController.java:[61,5] cannot find symbol
symbol  : method setValueRaw(java.lang.String)
location: class net.jnd.thesis.domain.Event
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:622)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more

我该如何解决?

整个 pom.xml 文件可在此处查看:

The entire pom.xml file can be seen here:

推荐答案

如果使用pluginManagement,则主要是为列出的插件设置/配置内容,而不是必须执行,除了默认情况下绑定到阶段的插件(例如maven-compiler-plugin例如).

If you use pluginManagement, you mainly do setting/config stuff for the listed plugins and not execute them necessarily except for plugins that bind to a phase by default (like the maven-compiler-plugin e.g.).

父pom中的pluginManagement通常用于为所有子项设置插件...

The pluginManagement in a parent pom is often used to set up the plugins for all children ...

因此,似乎(至少)您的一个插件(aspectj-maven-plugin?)需要在pluginManagement-tag之外的build-plugins-section中列出,以实现其目标.

So it seems that (at least) one of your plugins (aspectj-maven-plugin?) needs to be listed in the build-plugins-section outside the pluginManagement-tag to get it's goals executed.

尝试做某事:

<build>
 <pluginManagement>
   <plugins>
    ...
    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.2</version>
            <!-- NB: do not use 1.3 or 1.3.x due to MASPECTJ-90 and do not use 1.4
                due to declare parents issue -->
            <dependencies>
                <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see
                    MNG-2972) -->
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
    </plugin>
  </plugins>
 </pluginManagement>

 <plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
  </plugin>
 </plugins>
 ...
</build>

编辑 另外,您必须告诉eclipse m2e插件,有些目标(编译/测试-编译)与默认配置不符:

EDIT Additionally you have to tell the eclipse m2e plugin that there are some goals (compile/test-compile) that don't match it's default configuration:

<build>
 <pluginManagement>
<plugins>
     ...
     <plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
        <lifecycleMappingMetadata>
            <pluginExecutions>
                <pluginExecution>
                    <pluginExecutionFilter>
                        <groupId>org.codehaus.mojo</groupId>
                         <artifactId>aspectj-maven-plugin</artifactId>
                        <versionRange>[1.2,)</versionRange>
                <goals>
                    <goal>compile</goal>
                    <goal>test-compile</goal>
                </goals>
         </pluginExecutionFilter>
    <action>
        <execute />
    </action>
      </pluginExecution>
         </pluginExecutions>
    </lifecycleMappingMetadata>
  </configuration>
 </plugin>
</plugins>
</pluginManagement>
...

这篇关于&lt; pluginManagement&gt;标签会导致“找不到符号"在Maven2上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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