命令:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-gri
zzly2 -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=com.examp
le -DartifactId=simple-service -Dpackage=com.example -DarchetypeVersion=2.9
控制台:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent@69de5b4
java.lang.NoClassDefFoundError: org/apache/commons/collections/ExtendedProperties
at org.apache.velocity.runtime.RuntimeInstance.(RuntimeInstance.java:164)
at org.apache.velocity.app.VelocityEngine.(VelocityEngine.java:71)
at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent
.java:72)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303
)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionLi
stenerStackCallback.java:126)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStac
kCallback.java:68)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.ja
va:63)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToIni
tializableAdapter.java:45)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMaven
PluginManager.java:517)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.j
ava:121)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
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(LifecycleModuleBu
ilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBu
ilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(Si
ngleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.ExtendedProperties
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.ja
va:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:
271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 42 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.837 s
[INFO] Finished at: 2016-04-28T10:08:39+08:00
[INFO] Final Memory: 10M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default
-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archet
ype-plugin:2.2:generate failed: A required class was missing while executing org.apache.maven.plugin
s:maven-archetype-plugin:2.2:generate: org/apache/commons/collections/ExtendedProperties
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-archetype-plugin:2.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/plug
ins/maven-archetype-plugin/2.2/maven-archetype-plugin-2.2.jar
[ERROR] urls[1] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/arch
etype/archetype-catalog/2.2/archetype-catalog-2.2.jar
[ERROR] urls[2] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/arch
etype/archetype-descriptor/2.2/archetype-descriptor-2.2.jar
[ERROR] urls[3] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/arch
etype/archetype-registry/2.2/archetype-registry-2.2.jar
[ERROR] urls[4] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/arch
etype/archetype-common/2.2/archetype-common-2.2.jar
[ERROR] urls[5] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/net/sourceforge/jchar
det/jchardet/1.0/jchardet-1.0.jar
[ERROR] urls[6] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/codehaus/plexus/p
lexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[7] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/dom4j/dom4j/1.6.1/dom
4j-1.6.1.jar
[ERROR] urls[8] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/xml-apis/xml-apis/1.0
.b2/xml-apis-1.0.b2.jar
[ERROR] urls[9] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/jdom/jdom/1.0/jdom-1.
0.jar
[ERROR] urls[10] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/commons-io/commons-i
o/1.4/commons-io-1.4.jar
[ERROR] urls[11] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/codehaus/plexus/
plexus-velocity/1.1.8/plexus-velocity-1.1.8.jar
[ERROR] urls[12] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/velocity/
velocity/1.5/velocity-1.5.jar
[ERROR] urls[13] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/commons-lang/commons
-lang/2.1/commons-lang-2.1.jar
[ERROR] urls[14] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/oro/oro/2.0.8/oro-2.
0.8.jar
[ERROR] urls[15] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/codehaus/plexus/
plexus-utils/1.5.8/plexus-utils-1.5.8.jar
[ERROR] urls[16] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/rep
orting/maven-reporting-api/2.0.8/maven-reporting-api-2.0.8.jar
[ERROR] urls[17] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/dox
ia/doxia-sink-api/1.0-alpha-9/doxia-sink-api-1.0-alpha-9.jar
[ERROR] urls[18] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/commons-cli/commons-
cli/1.0/commons-cli-1.0.jar
[ERROR] urls[19] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/codehaus/plexus/
plexus-interactivity-api/1.0-alpha-5/plexus-interactivity-api-1.0-alpha-5.jar
[ERROR] urls[20] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/sha
red/maven-invoker/2.0.11/maven-invoker-2.0.11.jar
[ERROR] urls[21] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/commons-collections/
commons-collections/3.2.1/commons-collections-3.2.1.jar
[ERROR] urls[22] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/codehaus/groovy/
groovy/1.8.3/groovy-1.8.3.jar
[ERROR] urls[23] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/antlr/antlr/2.7.7/an
tlr-2.7.7.jar
[ERROR] urls[24] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/asm/asm/3.2/asm-3.2.
jar
[ERROR] urls[25] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/asm/asm-commons/3.2/
asm-commons-3.2.jar
[ERROR] urls[26] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/asm/asm-util/3.2/asm
-util-3.2.jar
[ERROR] urls[27] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/asm/asm-analysis/3.2
/asm-analysis-3.2.jar
[ERROR] urls[28] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/asm/asm-tree/3.2/asm
-tree-3.2.jar
[ERROR] urls[29] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/beanshell/bsh/2.
0b4/bsh-2.0b4.jar
[ERROR] urls[30] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/maven/sha
red/maven-script-interpreter/1.0/maven-script-interpreter-1.0.jar
[ERROR] urls[31] = file:/D:/MyDownloads/springmvcibatisprototype/.m2/repository/org/apache/ant/ant/1
.8.1/ant-1.8.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.apache.commons.collections.Extend
edProperties
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following arti
cles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
[WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultInputHandler@1ebe79
d3
java.lang.NullPointerException
at org.codehaus.plexus.components.interactivity.DefaultInputHandler.dispose(DefaultInputHand
ler.java:70)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultOutputHandler@2357c
179
java.lang.NullPointerException
at org.codehaus.plexus.components.interactivity.DefaultOutputHandler.dispose(DefaultOutputHa
ndler.java:53)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultInputHandler@773eac
15
java.lang.NullPointerException
at org.codehaus.plexus.components.interactivity.DefaultInputHandler.dispose(DefaultInputHand
ler.java:70)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] Problem disposing: org.codehaus.plexus.components.interactivity.DefaultOutputHandler@2e3a2
af8
java.lang.NullPointerException
at org.codehaus.plexus.components.interactivity.DefaultOutputHandler.dispose(DefaultOutputHa
ndler.java:53)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.dispose(PlexusLifecycleManager.java:368)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:173)
at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:590)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:315)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
主要的Error就是这个:
java.lang.NoClassDefFoundError: org/apache/commons/collections/ExtendedProperties
找不到这个类定义
上网找了一下找到了解决方法:
SOLUTION:
OK, turns out the problem was that for whatever reason the first time Maven downloaded the archives
some of the jar files came in corrupted. The Apache Commons Collections was one of these and generally the
first one encountered when trying to run any Maven build. The error messages from the command line
were not terribly enlightening and not until attempting to run the build from Eclipse did I see that about five
of the jar files were corrupted.
I deleted the corrupted files and re-ran Maven, this time finding one corrupted file so I deleted it again
and the third time was the charm.
Thanks to those who offered assistance, I am now officially started with Maven.
但是明明我们的本地资源库有这个玩意儿,为什么还是会报错呢,谁知道呢,
于是就把他们删了,再运行吧.
我的资源是在这个目录下的:D:\MyDownloads\springmvcibatisprototype\.m2\repository\commons-collections\commons-collections
我把它里面的文件夹剪切到其他地方再运行
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-gri
zzly2 -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=com.examp
le -DartifactId=simple-service -Dpackage=com.example -DarchetypeVersion=2.9
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
Downloading: https://repo.maven.apache.org/maven2/commons-collections/commons-collections/3.2.1/comm
ons-collections-3.2.1.pom
Downloaded: https://repo.maven.apache.org/maven2/commons-collections/commons-collections/3.2.1/commo
ns-collections-3.2.1.pom (13 KB at 2.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/commons-collections/commons-collections/3.2.1/comm
ons-collections-3.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/commons-collections/commons-collections/3.2.1/commo
ns-collections-3.2.1.jar (562 KB at 141.4 KB/sec)
[INFO] Generating project in Batch mode
[INFO] Archetype repository missing. Using the one from [org.glassfish.jersey.archetypes:jersey-quic
kstart-grizzly2:2.22.2] found in catalog remote
Downloading: https://repo.maven.apache.org/maven2/org/glassfish/jersey/archetypes/jersey-quickstart-
grizzly2/2.9/jersey-quickstart-grizzly2-2.9.jar
Downloaded: https://repo.maven.apache.org/maven2/org/glassfish/jersey/archetypes/jersey-quickstart-g
rizzly2/2.9/jersey-quickstart-grizzly2-2.9.jar (8 KB at 12.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/glassfish/jersey/archetypes/jersey-quickstart-
grizzly2/2.9/jersey-quickstart-grizzly2-2.9.pom
Downloaded: https://repo.maven.apache.org/maven2/org/glassfish/jersey/archetypes/jersey-quickstart-g
rizzly2/2.9/jersey-quickstart-grizzly2-2.9.pom (4 KB at 2.2 KB/sec)
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: jersey-quickstart-g
rizzly2:2.9
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.example
[INFO] Parameter: packageName, Value: com.example
[INFO] Parameter: package, Value: com.example
[INFO] Parameter: artifactId, Value: simple-service
[INFO] Parameter: basedir, Value: C:\Users\Administrator\Desktop\js
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\Users\Administrator\Desktop\js\simple-ser
vice
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.054 s
[INFO] Finished at: 2016-04-28T10:20:33+08:00
[INFO] Final Memory: 20M/167M
[INFO] ------------------------------------------------------------------------
参考:
Newbie problem getting basic functionality to work