Tuesday, April 24, 2012

My first simple maven project

Experience in first simple maven project

Last week (21st April 2012) Yarl IT Hub had conducted an online meeting about Java web programming techniques and fundamentals, followed by a session on Git source control, Maven build and initial project setup for crash course series. That day I heard about the Maven.


Set up the maven

I did the following set up to run the maven project.


If the maven installed correctly, the command prompt look like this.

 

 Create the first project.


  • In the commend prompt I typed "mvn archetype:generate -DarchetypeArtifactId=mavenarchetype-webapp -DgroupId=org.yarlithub.yschool -DartifactId=yschool"
  • It run  long time. finally It displayed the message "BUILD SUCCESS".
  • Then I changed my directory, where my project is created (yschool).
  • then I compiled my project by "mvn compile" command.
  • After I compiled, a folder 'target' was created into the yschool folder.
  • Then I add a jetty plugin to maven pom.xml
  • Run the command "mvn install jetty:run", It also run long time, finally it displayed the message "[INFO] Started Jetty Server"
  • Then I started my browser and type "http://localhost:8080/yschool/", the browser displayed "Hello World".
  • Then I go through yschool --->src ---> main ---> webapp --->index.jsp and edit text and reload the browser.

  

This is my first maven project.


1 comment:

  1. Good Blog Niroshan.. This is what I was looking for.

    Can you explain what happens when you run "mvn install jetty:run"? I mean how does it compile and run the system? Try to study how maven works. That will help you working around maven in future.

    ReplyDelete