To create java project from maven template
- Go to command project and navigate to the folder you want to create the project
- Type the command
mvn archetype:generate -DgroupId={project-packaging}
-DartifactId={project-name}
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
where {project-packing} and {project name} are the name of the package and project name provided.
- Above command creates the project with maven-archetype-quickstart template.
- Thus it will create /src/main/java and /src/test/java folder structure with pom.xml file.
- To make this eclipse project, navigate to your project folder in command prompt,
type mvn eclipse:eclipse
.project will be created.
- In Eclipse, File -> import -> Existing project from workspace.
Add compiler plugin in the pom.xml to tell maven which JDK version is used to compile your project.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>