Road to create java maven project.

In this post I explain the procedure to create java maven project.  Before creating maven project you must have following setup in your system.
  1. Java 
  2. Maven
  3. Eclipse
Create Maven project:  create a folder in your system as I created “MavenProject” folder in D drive. Open command prompt, go to created project and run below command.

mvn archetype:generate -DgroupId={ProjectPackage} -DartifactId={ProjectName} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Note: ProjectName and ProjectPackage replace this with your project name and packages  as I updated “SampeProject” and “com.maven.example”.


After build success you should see that maven project is created. Your created maven project looks like as below structure.

SampeProject
                    src/main/java
                    ******** com/ maven/ example
                    *****************App.java                                                          
                    src/test/java
                    ******** com/maven/example/
                    ****************AppTest.java             
                    pom.xml

Now maven project is created but we cannot import it on eclipse due to missing some eclipse required file as .project, .classes etc. So we need to convert this project into eclipse project by traversing created project on console and run below maven command.

mvn eclipse:eclipse


After build success, your created project is converted into eclipse maven project. Open eclipse and import this project, after importing project look like as below.


No comments:

Post a Comment

Leave your comments, queries, suggestion I will try to provide solution