Unable to create a new maven hello-world project

JavaMaven

Java Problem Overview


I am looking at few maven tutorial videos and then I ran into this command after installing maven:

mvn archetype:create -DgroupId=com.di.maven -DartifactId=hello-world

The build fails and throws the following error:

Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create 
(default-cli) on project standalone-pom: Unable to parse configuration of mojo 
org.apache.maven.plugins:maven-archetype-plugin:2.3:create for parameter #: Abstract 
class or interface 'org.apache.maven.artifact.repository.ArtifactRepository' cannot be 
instantiated -> [Help 1]

What is the reason and how can I fix it? I am running as an user in Ubuntu.

Java Solutions


Solution 1 - Java

change create to generate

mvn archetype:generate -DgroupId=com.di.maven -DartifactId=hello-world -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Solution 2 - Java

mvn archetype:create is deprecated in Maven 3.0.5 and beyond, as mentioned in the documentation

Use mvn archetype:generate instead:

> mvn archetype:generate -DarchetypeArtifactId=maven-archetype-archetype

This is an interactive command and will ask for values like groupId, artifactId, version, etc. You can also specify these values in the command and choose the non-interactive mode.

Solution 3 - Java

mvn archetype:generate 
  -DgroupId=com.biswajit.maven 
  -DartifactId=com.biswajit.maven 
  -DarchetypeArtifactId=maven-archetype-quickstart 
  -DinteractiveMode=false

Create does not work in maven 3.0.X or beyond. So use generate instead of create

Solution 4 - Java

Add

    <dependency>
     <groupId>commons-lang</groupId>
     <artifactId>commons-lang</artifactId>
     <version>2.3</version>
    </dependency>

to your pom file in

 {user.home}/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin/2.3

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLondon guyView Question on Stackoverflow
Solution 1 - JavaAhmet KarakayaView Answer on Stackoverflow
Solution 2 - JavaSureshView Answer on Stackoverflow
Solution 3 - Javauser5458751View Answer on Stackoverflow
Solution 4 - JavaSidhant101View Answer on Stackoverflow