Unable to create a new maven hello-world project

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.


Solution 1:

change create to generate

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

Solution 2:

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:

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