Maven - 为什么在“mvn clean”之后我需要执行“Maven更新项目”之前的“mvn包”? [英] Maven - Why after "mvn clean" I need to execute "Maven Update Project" before "mvn package"?
问题描述
mvn clean
我需要执行Maven>更新项目,然后运行 mvn package
,否则我在包装中的一个依赖关系中收到编译错误。 在运行Maven>更新项目之前,我的项目看起来不能正确编译我的项目,但我不确定。
这是正常吗?
- 我正在使用Eclipse,并通过mvn clean和{mvn package}运行为> Maven Build。
这是我的pom.xml:
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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.project< / groupId>
< artifactId> myProject< / artifactId>
< version> 0.0.1-SNAPSHOT< / version>
< packaging> war< / packaging>
< properties>
< jmockit.version> 0.0.1< / jmockit.version>
< / properties>
< build>
< testSourceDirectory> src / test / java / junit< / testSourceDirectory>
< resources>
< resource>
< directory> src / main / java< / directory>
< excludes>
< exclude> ** / *。java< / exclude>
< / excludes>
< / resource>
< / resources>
< testResources>
< testResource>
< directory> src / test / java / selenium< / directory>
< excludes>
< exclude> ** / *。java< / exclude>
< / excludes>
< / testResource>
< / testResources>
< pluginManagement>
< plugins>
<! - 需要Java 5,这是maven-compiler-plugin v2.3以来的默认值。 - >
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.5.1< / version>
< / plugin>
< / plugins>
< / pluginManagement>
< plugins>
< plugin>
< artifactId> maven-compiler-plugin< / artifactId>
< configuration>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>
< / plugin>
< plugin>
< artifactId> maven-war-plugin< / artifactId>
< version> 2.2< / version>
< configuration>
< failOnMissingWebXml> false< / failOnMissingWebXml>
< warSourceExcludes> src / main / resources / conf_development< / warSourceExcludes>
< webResources>
< resource>
< directory> src / main / resources / conf_production< / directory>
< targetPath> WEB-INF / classes /< / targetPath>
< includes>
< include> ** / *< / include>
< / includes>
< / resource>
< resource>
< directory> src / main / resources / conf< / directory>
< targetPath> WEB-INF / classes /< / targetPath>
< includes>
< include> ** / *< / include>
< / includes>
< / resource>
< / webResources>
< / configuration>
< / plugin>
< plugin>
< artifactId> maven-surefire-plugin< / artifactId>
< configuration>
< argLine>
-javaagent:$ {settings.localRepository}/ mockit / jmockit / $ {jmockit.version} / jmockit - $ {jmockit.version} .jar
< / argLine>
< / configuration>
< / plugin>
< / plugins>
< / build>
<依赖关系>
<依赖关系>
< groupId> asm< / groupId>
< artifactId> asm< / artifactId>
< version> 1.5.3< / version>
< / dependency>
<依赖关系>
< groupId> bouncycastle< / groupId>
< artifactId> bcprov-jdk14< / artifactId>
< version> 140< / version>
< / dependency>
<依赖关系>
< groupId> c3p0< / groupId>
< artifactId> c3p0< / artifactId>
< version> 0.9.1< / version>
< / dependency>
<依赖关系>
< groupId> c3p0< / groupId>
< artifactId> c3p0-oracle-thin-extras< / artifactId>
< version> 0.9.0.2< / version>
< / dependency>
<依赖关系>
< groupId> commons-betwixt< / groupId>
< artifactId> commons-betwixt< / artifactId>
< version> 0.7< / version>
< / dependency>
<依赖关系>
< groupId> com.google.code.gson< / groupId>
< artifactId> gson< / artifactId>
< version> 1.4< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.commons< / groupId>
< artifactId> commons-email< / artifactId>
< version> 1.2< / version>
< / dependency>
<依赖关系>
< groupId> net.sf.ehcache< / groupId>
< artifactId> ehcache-core< / artifactId>
< version> 2.4.2< / version>
< / dependency>
<依赖关系>
< groupId> com.googlecode.ehcache-spring-annotations< / groupId>
< artifactId> ehcache-spring-annotations< / artifactId>
< version> 1.1.3< / version>
< / dependency>
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-annotations< / artifactId>
< version> 3.4.0.GA< / version>
< / dependency>
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-entitymanager< / artifactId>
< version> 3.4.0.GA< / version>
< / dependency>
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-core< / artifactId>
< version> 3.3.2.GA< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.httpcomponents< / groupId>
< artifactId> httpclient< / artifactId>
< version> 4.1.2< / version>
< / dependency>
<依赖关系>
< groupId> net.sf.json-lib< / groupId>
< artifactId> json-lib< / artifactId>
< version> 2.4< / version>
< type> pom< / type>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-jdbc< / artifactId>
< version> 2.5.6< / version>
< / dependency>
<依赖关系>
< groupId> net.fckeditor< / groupId>
< artifactId> java-core< / artifactId>
< version> 2.4< / version>
< / dependency>
<依赖关系>
< groupId> backport-util-concurrent< / groupId>
< artifactId> backport-util-concurrent< / artifactId>
< version> 3.1< / version>
< / dependency>
<依赖关系>
< groupId> com.oracle< / groupId>
< artifactId> ojdbc14< / artifactId>
< version> 10.2.0.1.0< / version>
< / dependency>
<依赖关系>
< groupId> com.ibm.icu< / groupId>
< artifactId> icu4j< / artifactId>
< version> 3.8< / version>
< / dependency>
<依赖关系>
< groupId> mockit< / groupId>
< artifactId> jmockit< / artifactId>
< version> $ {jmockit.version}< / version>
< / dependency>
<依赖关系>
< groupId> joda-time< / groupId>
< artifactId> joda-time< / artifactId>
< version> 2.0< / version>
< / dependency>
<依赖关系>
< groupId> com.lowagie< / groupId>
< artifactId> itext< / artifactId>
< version> 2.1.0< / version>
< / dependency>
<依赖关系>
< groupId> atg.taglib.json< / groupId>
< artifactId> json-taglib< / artifactId>
< version> 0.4.1< / version>
< / dependency>
<依赖关系>
< groupId> commons-httpclient< / groupId>
< artifactId> commons-httpclient< / artifactId>
< version> 3.1< / version>
< / dependency>
<依赖关系>
< groupId> net.sourceforge.jexcelapi< / groupId>
< artifactId> jxl< / artifactId>
< version> 2.6< / version>
< / dependency>
<依赖关系>
< groupId> log4j< / groupId>
< artifactId> log4j< / artifactId>
< version> 1.2.17< / version>
< / dependency>
<依赖关系>
< groupId> org.mockito< / groupId>
< artifactId> mockito-all< / artifactId>
< version> 1.8.5< / version>
< / dependency>
<依赖关系>
< groupId> org.quartz-scheduler< / groupId>
< artifactId> quartz< / artifactId>
< version> 1.8.4< / version>
< / dependency>
<依赖关系>
< groupId> org.seleniumhq.selenium< / groupId>
< artifactId> selenium-server< / artifactId>
< version> 2.25.0< / version>
< type> pom< / type>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring< / artifactId>
< version> 2.5.6.SEC03< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-agent< / artifactId>
< version> 2.5.6.SEC03< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-test< / artifactId>
< version> 2.5.6.SEC03< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-config-browser-plugin< / artifactId>
< version> 2.2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-convention-plugin< / artifactId>
< version> 2.2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-core< / artifactId>
< version> 2.2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-jasperreports-plugin< / artifactId>
< version> 2.2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-jfreechart-plugin< / artifactId>
< version> 2.2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-json-plugin< / artifactId>
< version> 2.2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-spring-plugin< / artifactId>
< version> 2.2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.velocity< / groupId>
< artifactId> velocity< / artifactId>
< version> 1.6.3< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.velocity< / groupId>
< artifactId> velocity-tools< / artifactId>
< version> 1.3< / version>
< / dependency>
<依赖关系>
< groupId> com.yahoo.platform.yui< / groupId>
< artifactId> yuicompressor< / artifactId>
< version> 2.4.6< / version>
< / dependency>
<依赖关系>
< groupId> commons-lang< / groupId>
< artifactId> commons-lang< / artifactId>
< version> 2.5< / version>
< / dependency>
<依赖关系>
< groupId> net.sf.jodreports< / groupId>
< artifactId> jodreports< / artifactId>
< version> 2.4.0< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework.ws< / groupId>
< artifactId> spring-oxm< / artifactId>
< version> 1.5.9< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework.ws< / groupId>
< artifactId> spring-ws-core< / artifactId>
< version> 1.5.9< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework.ws< / groupId>
< artifactId> spring-oxm-tiger< / artifactId>
< version> 1.5.9< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework.ws< / groupId>
< artifactId> spring-ws-core-tiger< / artifactId>
< version> 1.5.9< / version>
< / dependency>
<依赖关系>
< groupId> javax.xml.bind< / groupId>
< artifactId> jaxb-api< / artifactId>
< version> 2.1< / version>
< / dependency>
<依赖关系>
< groupId> com.sun.xml.bind< / groupId>
< artifactId> jaxb-xjc< / artifactId>
< version> 2.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.ws.commons.axiom
< / groupId>
< artifactId> axiom-api< / artifactId>
< version> 1.2.5< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.ws.commons.axiom
< / groupId>
< artifactId> axiom-impl< / artifactId>
< version> 1.2.5< / version>
< / dependency>
<依赖关系>
< groupId> javax.xml< / groupId>
< artifactId> jaxrpc-api< / artifactId>
< version> 1.1< / version>
< / dependency>
<依赖关系>
< groupId> org.seleniumhq.selenium.client-drivers< / groupId>
< artifactId> selenium-java-client-driver< / artifactId>
< version> 1.0.1< / version>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 4.11< / version>
< / dependency>
<依赖关系>
< groupId> org.acegisecurity< / groupId>
< artifactId> acegi-security< / artifactId>
< version> 1.0.7< / version>
< / dependency>
<依赖关系>
< groupId> citizen< / groupId>
< artifactId> citizen< / artifactId>
< version> citizen< / version>
< / dependency>
<依赖关系>
< groupId> jstl< / groupId>
< artifactId> jstl< / artifactId>
< version> 1.2< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> javax.servlet< / groupId>
< artifactId> servlet-api< / artifactId>
< version> 2.4< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> javax.servlet.jsp< / groupId>
< artifactId> jsp-api< / artifactId>
< version> 2.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> jasperreports< / groupId>
< artifactId> jasperreports< / artifactId>
< version> 3.5.3< / version>
< / dependency>
< / dependencies>
< / project>
错误:
(记住lib的错误它是一个内部的lib,它的工作正常后Maven>更新项目)
[INFO]编译2595源文件到C:\Users\user\Documents\Dev\workspace\project\target\classes
[INFO] -------------- -----------------------------------------------
[错误]编译错误:
[INFO] ------------------------------------ -------------------------
[错误] C:\Users\user\Documents\Dev\workspace\\ \\project\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38
,34]无法访问org.apache。 axis.client.Service
没有找到org.apache.axis.client.Service的类文件
Resolution2Locator r2 = new Resolution2Locator();
[INFO] 1错误
[INFO] ---------------------------------- ---------------------------
[INFO] ---------------- -------------------------------------------------- ------
[INFO] BUILD FAILURE
[INFO] ---------------------------- --------------------------------------------
[信息]总时间:2:09.448s
[INFO]完成日期:Fri Mar 22 11:55:14 BRT 2013
[INFO] Final Memory:25M / 274M
[INFO] - -------------------------------------------------- --------------------
[ERROR]无法执行目标org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile)项目项目:编译失败
[错误] C:\Users\user\Documents\Dev\workspace\project
\src\main\ java\com\project\jobs\citizen\model\service\CitizenService.java:[38
,34]无法访问org.apache.axis.client.Service
[错误]类文件为org.apache.axis.client.Service找不到
[ERROR] Resolution2Locator r2 = new Resolution2Locator();
[ERROR] - > [帮助1]
org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标org.apache.maven.plugins:maven-compiler-plugin:2.5.1:在项目中编译(default-compile)u
nico:编译失败
C:\Users\user\Documents\Dev\workspace\project\src\main\java\com\project\jobs\\ \\ citizen\model\service\CitizenService.java:[38,34]可以
不为org.apache.axis.client访问org.apache.axis.client.Service
类文件。服务未找到
Resolution2Locator r2 = new Resolution2Locator(); $ org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor。)
java:153)
在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder。 java:84)
在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
在org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter。 java:183)
在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
在org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
在org .apache.maven.cli.MavenCli.doMain(MavenCli .java:196)
在org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
在java.lang.reflect.Method.invoke(Method.java :597)
在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java :230)
在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java :352)
导致:org.apache.maven.plugin.CompilationFailureException:编译失败
C:\Users\user\Documents\Dev\workspace\project\src\\ \\main\java\com\project\jobs\\ citizen\model\service\CitizenService.java:[38,34]可以
不访问org.apache.axis.client.Service
org.apache.axis.client.Service的类文件没有找到
Resolution2Locator r2 = new Resolution2Locator();
在org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
在org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19更多
[错误]
[错误]
[错误]有关错误和可能的解决方案的更多信息,请阅读以下文章:
[ERROR ] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
发生这种情况:
-
mvn clean
删除目标
目录 -
mvn package
执行一些工作,但是由于缺少依赖关系,因此遇到编译错误。这就是为什么目标文件夹出错。 - 在Eclipse中运行Maven> Update Project会使Eclipse执行自己的编译,与Maven分开。 Eclipse具有与Maven不同的类路径,因此它的编译成功。现在,
目标
目录具有所有编译的类。 - 重新运行
mvn package
现在成功,因为它发现所有的类都已经编译完成,不需要执行任何编译。
最终,问题在 pom.xml
中的项目配置中。我有同样的问题,在添加缺少的依赖项后,我用Maven成功编译了项目。
I'm making some tests and I would like to understand why after execute the command mvn clean
I need to execute "Maven > Update Project" before run mvn package
, otherwise I get a compilation error in one of my dependencies during the packaging.
It looks like my project doesn't compile correctly my project before running "Maven > Update Project", but I'm not sure. Is this normal?
- I'm using Eclipse and run the commands {mvn clean} and {mvn package} via "Run as > Maven Build".
Here is my 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.project</groupId>
<artifactId>myProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<jmockit.version>0.0.1</jmockit.version>
</properties>
<build>
<testSourceDirectory>src/test/java/junit</testSourceDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java/selenium</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<!-- Need Java 5, which is the default since v2.3 of the maven-compiler-plugin. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceExcludes>src/main/resources/conf_development</warSourceExcludes>
<webResources>
<resource>
<directory>src/main/resources/conf_production</directory>
<targetPath>WEB-INF/classes/</targetPath>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources/conf</directory>
<targetPath>WEB-INF/classes/</targetPath>
<includes>
<include>**/*</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}"/mockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
</argLine>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
<version>140</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0-oracle-thin-extras</artifactId>
<version>0.9.0.2</version>
</dependency>
<dependency>
<groupId>commons-betwixt</groupId>
<artifactId>commons-betwixt</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>net.fckeditor</groupId>
<artifactId>java-core</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>backport-util-concurrent</groupId>
<artifactId>backport-util-concurrent</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.1.0</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>mockit</groupId>
<artifactId>jmockit</artifactId>
<version>${jmockit.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>atg.taglib.json</groupId>
<artifactId>json-taglib</artifactId>
<version>0.4.1</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.25.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-agent</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jasperreports-plugin</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jfreechart-plugin</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.yahoo.platform.yui</groupId>
<artifactId>yuicompressor</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>net.sf.jodreports</groupId>
<artifactId>jodreports</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-oxm</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-oxm-tiger</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core-tiger</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom
</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom
</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium.client-drivers</groupId>
<artifactId>selenium-java-client-driver</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.acegisecurity</groupId>
<artifactId>acegi-security</artifactId>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>citizen</groupId>
<artifactId>citizen</artifactId>
<version>citizen</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>3.5.3</version>
</dependency>
</dependencies>
</project>
The error:
(Remembering that the lib with error it's an internal lib and it work just fine after "Maven > Update Project")
[INFO] Compiling 2595 source files to C:\Users\user\Documents\Dev\workspace\project\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] C:\Users\user\Documents\Dev\workspace\project\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38
,34] cannot access org.apache.axis.client.Service
class file for org.apache.axis.client.Service not found
Resolution2Locator r2 = new Resolution2Locator ();
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:09.448s
[INFO] Finished at: Fri Mar 22 11:55:14 BRT 2013
[INFO] Final Memory: 25M/274M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project project: Compilation failure
[ERROR] C:\Users\user\Documents\Dev\workspace\project
\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38
,34] cannot access org.apache.axis.client.Service
[ERROR] class file for org.apache.axis.client.Service not found
[ERROR] Resolution2Locator r2 = new Resolution2Locator();
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project u
nico: Compilation failure
C:\Users\user\Documents\Dev\workspace\project\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38,34] can
not access org.apache.axis.client.Service
class file for org.apache.axis.client.Service not found
Resolution2Locator r2 = new Resolution2Locator ();
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
C:\Users\user\Documents\Dev\workspace\project\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38,34] can
not access org.apache.axis.client.Service
class file for org.apache.axis.client.Service not found
Resolution2Locator r2 = new Resolution2Locator ();
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Here is what happens:
mvn clean
deletes thetarget
directorymvn package
performs some work, but then encounters a compilation error due to a missing dependency. That's why the target folder is in error.- Running Maven > Update Project in Eclipse causes Eclipse to perform its own compilation, separate from Maven. Eclipse has a different classpath than Maven, so its compilation succeeds. Now the
target
directory has all the compiled classes. - Re-running
mvn package
now succeeds, because it finds all the classes already compiled and doesn't need to perform any compilation.
Ultimately, the problem is in the project configuration in pom.xml
. I had the same problem, and after adding the missing dependency I successfully compiled project with Maven.
这篇关于Maven - 为什么在“mvn clean”之后我需要执行“Maven更新项目”之前的“mvn包”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!