这在Windows上运行良好,但在Linux上运行不正常,我不知道我在这里做错了什么。
在我转到我的maven项目目录,包含POM.xml文件的目录和“mvn package -e”之后,这是控制台输出:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building functionalTests
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/eclipse/m2e/lifecycle-mapping/1.0.0/lifecycle-mapping-1.0.0.pom
[INFO] Unable to find resource 'org.eclipse.m2e:lifecycle-mapping:pom:1.0.0' in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/eclipse/m2e/lifecycle-mapping/1.0.0/lifecycle-mapping-1.0.0.pom
[INFO] Unable to find resource 'org.eclipse.m2e:lifecycle-mapping:pom:1.0.0' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.eclipse.m2e:lifecycle-mapping
Reason: POM 'org.eclipse.m2e:lifecycle-mapping' not found in repository: Unable to download the artifact from any repository
org.eclipse.m2e:lifecycle-mapping:pom:1.0.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.eclipse.m2e:lifecycle-mapping
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build project for plugin 'org.eclipse.m2e:lifecycle-mapping': POM 'org.eclipse.m2e:lifecycle-mapping' not found in repository: Unable to download the artifact from any repository
org.eclipse.m2e:lifecycle-mapping:pom:1.0.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.eclipse.m2e:lifecycle-mapping
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1557)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindPluginToLifecycle(DefaultLifecycleExecutor.java:1503)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappings(DefaultLifecycleExecutor.java:1282)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:534)
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:616)
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.InvalidPluginException: Unable to build project for plugin 'org.eclipse.m2e:lifecycle-mapping': POM 'org.eclipse.m2e:lifecycle-mapping' not found in repository: Unable to download the artifact from any repository
org.eclipse.m2e:lifecycle-mapping:pom:1.0.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.eclipse.m2e:lifecycle-mapping
at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:293)
at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:205)
at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)
at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
... 18 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.eclipse.m2e:lifecycle-mapping' not found in repository: Unable to download the artifact from any repository
org.eclipse.m2e:lifecycle-mapping:pom:1.0.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.eclipse.m2e:lifecycle-mapping
at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:251)
at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:277)
... 22 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository
org.eclipse.m2e:lifecycle-mapping:pom:1.0.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
... 24 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
... 26 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Wed Sep 04 12:38:23 EEST 2013
[INFO] Final Memory: 4M/15M
这是我的pom.xml文件
<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>
<groupId>com.pragmaticqa.tests</groupId>
<artifactId>mailCheckerTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>functionalTests</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<displayProps>target/selenium/display.properties</displayProps>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.33.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.33.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<build>
<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.0,)</versionRange>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<includes>
<include>**/*Test*.java</include>
</includes>
<systemPropertyVariables>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
这是“mvn -version”
的输出Apache Maven 2.2.1 (rdebian-1)
Java version: 1.6.0_27
Java home: /usr/lib/jvm/java-6-openjdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-45-generic" arch: "i386" Family: "unix"
答案 0 :(得分:2)
问题的根本原因是不存在的插件lifecycle-mapping
无法从任何存储库下载工件org.eclipse.m2e:lifecycle-mapping:pom:1.0.0
问题的解决方案在于:m2e lifecycle-mapping not found
修改强>
建议避免使用m2eclipse:
在lifecycle-mapping
个人资料中定义插件dev
,并仅在eclipse中激活此个人资料。因此,当您在CI服务器上运行它时(没有dev
配置文件):不会暗示插件。
将其添加到您的pom.xml:
<profiles>
<profile>
<id>dev</id>
<build>
<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.0,)</versionRange>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</plugin>
</build>
</profile>
</profiles>
您还需要从默认构建部分删除插件。
默认情况下,dev
配置文件不会处于活动状态,因此默认情况下插件不会运行。
要使用插件运行构建,您需要激活配置文件。有不同的方法:
-Pdev
添加到mvn命令行为此,请在settings.xml中添加以下行
<settings>
...
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>
注意:对于最后一个解决方案,您必须确保eclipse使用的maven安装将使用此settings.xml(再一次,我不是eclipse用户......所以我不知道如何确保)
答案 1 :(得分:0)
从项目目录运行mvn eclipse:eclipse
,这应该可以解决您的m2e生命周期插件错误。