我是一个初学者,试图安装并创建我的第一个项目。 我在Windows 8上安装了Maven,我遇到了问题。
我没有创建settings.xml文件。 这个命令似乎揭示了一个问题:
如果我尝试创建一个快速启动项目,我会得到这个:
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.1
即使查看网络上的其他问题,我也找不到解决此问题的方法,我有人可以提供帮助吗?
EDIT 1 --------------------------------------------- -------------------
使用tis命令:
mvn -X archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.1
以下是我可以在此处复制/粘贴的最后一个调试行:
[DEBUG] Velocimacro : Velocimacro : initialization complete.
[DEBUG] RuntimeInstance successfully initialized.
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate' with basic configurator -->
[DEBUG] (f) archetypeArtifactId = maven-archetype-quickstart
[DEBUG] (f) archetypeCatalog = remote,local
[DEBUG] (f) archetypeVersion = 1.1
[DEBUG] (f) basedir = C:\Program Files\apache\repository
[DEBUG] (f) interactiveMode = true
[DEBUG] (f) localRepository = id: local
url: file:///C:/Users/B/.m2/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]
[DEBUG] (f) remoteArtifactRepositories = [ id: central
url: https://repo.maven.apache.org/maven2
layout: default
snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => daily]
]
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@320a8ebf
[DEBUG] -- end configuration --
[INFO] Generating project in Interactive mode
[DEBUG] Searching for remote catalog: https://repo.maven.apache.org/maven2/archetype-catalog.xml
[DEBUG] Using catalog C:\Users\B\.m2\repository\archetype-catalog.xml
[DEBUG] Not found archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 in cache
[DEBUG] Found archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 in cache: C:\Users\B\.m2\repository\org\apach
[DEBUG] checking fileset archetype status on C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-archetype-quickstart\1.
[DEBUG] Searching for META-INF/maven/archetype-metadata.xml inside C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-a
[DEBUG] - META-INF/maven/archetype.xml
[DEBUG] - META-INF/DEPENDENCIES
[DEBUG] - META-INF/LICENSE
[DEBUG] - META-INF/NOTICE
[DEBUG] - archetype-resources/pom.xml
[DEBUG] - archetype-resources/src/test/java/AppTest.java
[DEBUG] - archetype-resources/src/main/java/App.java
[DEBUG] Found archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 in cache: C:\Users\B\.m2\repository\org\apach
[DEBUG] checking old archetype status on C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-archetype-quickstart\1.1\ma
[DEBUG] Searching for META-INF/maven/archetype.xml inside C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-archetype-
[DEBUG] - META-INF/maven/archetype.xml
[DEBUG] Entry found
[DEBUG] Found archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 in cache: C:\Users\B\.m2\repository\org\apach
[DEBUG] Searching for META-INF/maven/archetype.xml inside C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-archetype-
[DEBUG] - META-INF/maven/archetype.xml
[DEBUG] Entry found
[DEBUG] Creating ArchetypeConfiguration from legacy descriptor and Properties
[DEBUG] Adding requiredProperty groupId
[DEBUG] Setting property groupId=null
[DEBUG] Adding requiredProperty artifactId
[DEBUG] Setting property artifactId=null
[DEBUG] Adding requiredProperty version
[DEBUG] Setting property version=null
[DEBUG] Adding requiredProperty package
[DEBUG] Setting property package=null
[DEBUG] Required properties before content sort: [groupId, artifactId, version, package]
[DEBUG] Required properties after content sort: [groupId, artifactId, version, package]
Define value for property 'groupId': org.exemple.demo
Define value for property 'artifactId': mon-appli
Define value for property 'version' 1.0-SNAPSHOT: :
Define value for property 'package' org.exemple.demo: :
Confirm properties configuration:
groupId: org.exemple.demo
artifactId: mon-appli
version: 1.0-SNAPSHOT
package: org.exemple.demo
Y: :
[DEBUG] Archetype generation configuration confirmed
[DEBUG] Found archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 in cache: C:\Users\B\.m2\repository\org\apach
[DEBUG] Found archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 in cache: C:\Users\B\.m2\repository\org\apach
[DEBUG] checking fileset archetype status on C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-archetype-quickstart\1.
[DEBUG] Searching for META-INF/maven/archetype-metadata.xml inside C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-a
[DEBUG] - META-INF/maven/archetype.xml
[DEBUG] - META-INF/DEPENDENCIES
[DEBUG] - META-INF/LICENSE
[DEBUG] - META-INF/NOTICE
[DEBUG] - archetype-resources/pom.xml
[DEBUG] - archetype-resources/src/test/java/AppTest.java
[DEBUG] - archetype-resources/src/main/java/App.java
[DEBUG] checking old archetype status on C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-archetype-quickstart\1.1\ma
[DEBUG] Searching for META-INF/maven/archetype.xml inside C:\Users\B\.m2\repository\org\apache\maven\archetypes\maven-archetype-
[DEBUG] - META-INF/maven/archetype.xml
[DEBUG] Entry found
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.1
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: C:\Program Files\apache\repository
[INFO] Parameter: package, Value: org.exemple.demo
[INFO] Parameter: groupId, Value: org.exemple.demo
[INFO] Parameter: artifactId, Value: mon-appli
[INFO] Parameter: packageName, Value: org.exemple.demo
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.131 s
[INFO] Finished at: 2018-03-13T12:28:25+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalon
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
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: org.apache.maven.plugin.MojoFailureException: Error merging velocity templates
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute (CreateProjectFromArchetypeMojo.java:206)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
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]
[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
←[0m←[0m
C:\Program Files\apache\repository>
EDIT 2 --------------------------------------------- --------------------
我找到了问题的根源:
apache-maven-3.5.3文件位于c:\ Program Files。
中创建的文件夹中我在c:\ apache \ apache-maven-3.5.3的根目录下更改并创建了一个目录,现在脚本可以正常运行。