- Install jdk 1.7 and set the class path.
- Unzip the to apache-maven-3.0.4-bin.zip the directory you wish to install maven. The sub directory apache-maven-3.0.4 will be created from archive in your choosen directory( C:\Program Files\Apache Software Foundation\apache-maven-3.0.4).
- Add %JAVA_HOME% variable in your user variables with the value e.g. C:\Program Files\Java\jdk1.7 .
- Add C:\Program Files\Apache Software Foundation\apache-maven-3.0.4\bin in you "Path" environment variable.
- Open a new command prompt and run mvn -v to verify that it is correctly installed
Steps to create build and run a maven project:
- Create a project directory where you wants to create the maven project.
- Go to that directory via command prompt.
- Create project using the command "mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=org.yarlithub.yschool -DartifactId=yschool-mini-vanaja".
- Then go to your project directory (yschool-mini-vanaja).
- Then run the command with "mvn compile".
- This will create a folder target with compile classes.
- To run our project we need a web server. For testing purpose we can use jetty. So we need to add a jetty plug-in to maven pom.xml file. Plug-in should be added under build tag.
<project ...>
<dependencies>
<.../
</dependencies>
<build>
<finalName>yschool</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<!--<configuration>-->
<!--<scanIntervalSeconds>10</scanIntervalSeconds>-->
<!--<stopKey>stop</stopKey>-->
<!--<stopPort>9999</stopPort>-->
<!--</configuration>-->
<executions>
<execution>
<id>start-jetty</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </build> </project>
9. After adding the plug-in run the command "mvn install jetty:run".
10. Now Jetty will be start and project will be deployed there.
11. Now go to your browser and type http://localhost:8080/<project-name>
12. There will be your page displaying.
9. After adding the plug-in run the command "mvn install jetty:run".
10. Now Jetty will be start and project will be deployed there.
11. Now go to your browser and type http://localhost:8080/<project-name>
12. There will be your page displaying.
No comments:
Post a Comment