Steps To Create Project By Maven
First need to install JDK1.5 +
JDK 1.5
Install JDK 1.5 at c:/Program Files/Java
After completion of JDK setup, Set JAVA_HOME Env.
Maven
1. Unzip the distribution archive, i.e. apache-maven-2.0.9-bin.zip to the directory you wish to install Maven 2.0.9. These instructions assume you chose "C:\Program Files\Apache Software Foundation\" . The subdirectory apache-maven-2.0.9 will be created from the archive.
2. Add the M2_HOME environment variable by opening up the system properties (WinKey + Pause), selecting the "Advanced" tab, and the "Environment Variables" button, then adding the M2_HOME variable in the user variables with the value "C:\Program Files\Apache Software Foundation\apache-maven-2.0.9" . Note : for Maven < 2.0.9, be sure that the M2_HOME doesn't have a '\' as last character.
3. In the same dialog, add the M2 environment variable in the user variables with the value "%M2_HOME%\bin" .
4. Optional : in the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value "-Xms256m -Xmx512m" . This environment variable can be used to supply extra options to Maven.
5. In the same dialog, update/create the Path environment variable in the user variables with the value "%M2%;%Path%" to add maven available in the command line.
6. In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. "C:\Program Files\Java\jdk1.5.0_02" and that "%JAVA_HOME%\bin" is in your Path environment variable.
7. Open a new command prompt (Winkey + R then type "cmd" ) and run "mvn --version" to verify that it is correctly installed.
8. Download Development\trunk\SampleProject from SVN.
9. Set Environment variable ‘ JAVA_HOME ‘and ‘M2_HOME ‘
10. Then run the following command for create a project.
mvn archetype:create -DgroupId=com.fulcrum.project -DartifactId=sample-springMVC-Project
mvn archetype:create -DgroupId=com.fulcrum.project -DartifactId=sample-springMVC-Project
11. then we need to change in pom.xml file delete the src-folder and open the pom.xml file to change the packaging of your parent project to pom
<packaging>pom</ packaging>
<packaging>pom</ packaging>
12. From the command-line change to the "sample-springMVC-Project" project directory and create some modules like core, web, report.
mvn archetype:create -DgroupId=com.fulcrum.project.core -DartifactId=springMVC-core
mvn archetype:create -DgroupId=com.fulcrum.project.web -DartifactId=springMVC-web
mvn archetype:create -DgroupId=com.fulcrum.project.report -DartifactId=springMVC-report
mvn archetype:create -DgroupId=com.fulcrum.project.core -DartifactId=springMVC-core
mvn archetype:create -DgroupId=com.fulcrum.project.web -DartifactId=springMVC-web
mvn archetype:create -DgroupId=com.fulcrum.project.report -DartifactId=springMVC-report
13. Now our modular project directory structure is complete. After completion of directory structure we need to add dependencies in our pom.xml file according to our requirement. For adding the jar file please refer this site http://mvnrepository.com/
14. like we are developing spring MVC project with Hibernate so we need to add jar in our pom.xml file. Use the following tags for adding the jar files.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</dependencyManagement>
15. After defining all dependencies in pom.xml need to run following commands on command-line
mvn install (for creating .m2 folder in your c:\ drive )
mvn clean compile ( for creating jar file of core project)
mvn package ( for creating war file of web project)
mvn install (for creating .m2 folder in your c:\ drive )
mvn clean compile ( for creating jar file of core project)
mvn package ( for creating war file of web project)
16. Project setup with eclipse .Following command u need to run on command-line
project-parent > mvn eclipse:clean
project -parent > mvn -U -DdownloadSources -Dwtpversion=1.5 eclipse:eclipse
project -parent > mvn -Declipse.workspace="<workspace_home>” eclipse:add-maven-repo
project-parent > mvn eclipse:clean
project -parent > mvn -U -DdownloadSources -Dwtpversion=1.5 eclipse:eclipse
project -parent > mvn -Declipse.workspace="<workspace_home>” eclipse:add-maven-repo
17. Import projects into eclipse.
18. Run the application and run the Junit test cases.
No comments:
Post a Comment