我刚刚开始使用maven,我目前正在关注http://www.sonatype.com/books/mvnex-book/reference/simple-project-sect-create-simple.html中的文章:
要启动新的Maven项目,请使用命令行中的Maven Archetype插件。运行原型:生成目标,选择原型#77,然后输入“Y”确认并生成新项目:
我的环境是:
albert@albertkam:~/java/mvn-test> mvn -v
Apache Maven 3.0.1 (r1038046; 2010-11-23 17:58:32+0700)
Java version: 1.6.0_22
Java home: /home/albert/java/jdk1.6.0_22/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.34-12-desktop" arch: "i386" Family: "unix"
这就是我所做的 mvn archetype:generate (在我的情况下,似乎快速启动原型是98?)
....
98: remote -> maven-archetype-quickstart (An archetype which contains a sample Maven project.)
....
360: remote -> wikbook.archetype (-)
361: remote -> circumflex-archetype (-)
362: remote -> javg-minimal-archetype (-)
Choose a number: 98: 98
Choose version:
1: 1.0-alpha-1
2: 1.0-alpha-2
3: 1.0-alpha-3
4: 1.0-alpha-4
5: 1.0
6: 1.1
Choose a number: 6: 1
Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1/maven-archetype-quickstart-1.0-alpha-1.jar
[WARNING] Checksum validation failed, expected 10f8e92bdec884d353c6b6232feaf3f47e220ec7 but is 4801a224d23f43da2013e35696e278f59c24c1a3 for http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1/maven-archetype-quickstart-1.0-alpha-1.jar
[WARNING] Checksum validation failed, expected 10f8e92bdec884d353c6b6232feaf3f47e220ec7 but is 4801a224d23f43da2013e35696e278f59c24c1a3 for http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1/maven-archetype-quickstart-1.0-alpha-1.jar
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1/maven-archetype-quickstart-1.0-alpha-1.jar (3 KB at 2.6 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1/maven-archetype-quickstart-1.0-alpha-1.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1/maven-archetype-quickstart-1.0-alpha-1.pom (299 B at 0.4 KB/sec)
Define value for property 'groupId': : org.albertkam
Define value for property 'artifactId': : firstTest
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': org.albertkam: :
Confirm properties configuration:
groupId: org.albertkam
artifactId: firstTest
version: 1.0-SNAPSHOT
package: org.albertkam
Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0-alpha-1
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.albertkam
[INFO] Parameter: packageName, Value: org.albertkam
[INFO] Parameter: package, Value: org.albertkam
[INFO] Parameter: artifactId, Value: firstTest
[INFO] Parameter: basedir, Value: /home/albert/java/mvn-test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[ERROR] Error reading POM
org.apache.maven.archetype.old.ArchetypeTemplateProcessingException: Error reading POM
at org.apache.maven.archetype.old.DefaultOldArchetype.processTemplates(DefaultOldArchetype.java:511)
at org.apache.maven.archetype.old.DefaultOldArchetype.createArchetype(DefaultOldArchetype.java:336)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.processOldArchetype(DefaultArchetypeGenerator.java:142)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:110)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:149)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:209)
at org.apache.maven.archetype.DefaultArchetypeManager.generateProjectFromArchetype(DefaultArchetypeManager.java:71)
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:190)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
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:316)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
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.codehaus.plexus.util.xml.pull.XmlPullParserException: Expected root element 'project' but found 'model' (position: START_TAG seen <model>... @1:7)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:4090)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:4025)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:4039)
at org.apache.maven.archetype.old.DefaultOldArchetype.processTemplates(DefaultOldArchetype.java:503)
... 28 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:08.416s
[INFO] Finished at: Tue Jan 11 16:47:09 WIT 2011
[INFO] Final Memory: 6M/56M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.0:generate (default-cli) on project standalone-pom: Error reading POM -> [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 articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
此错误的原因是什么?我错过了什么吗?
很遗憾在这里问这个问题,但无论如何我可以打包'代码示例'部分吗?我为输出消息选择了“代码示例”部分以保留新行,“blockquote”不会这样做。
答案 0 :(得分:7)
尝试使用最新版本的原型1.1,这是您提供的默认选项(6)。
选择一个数字:6:6
如果您只是在不输入选项的情况下按Enter键,则在显示默认值时,将选择默认值并且不会覆盖默认值。