Hello world Maven
Step 1: Download the maven from http://maven.apache.org/download.html
Step 2: Set the path like below,
Variable Name: M2_Home Value: Path of the maven (c:\apache-maven-3.0.4) Variable Name: java_home Value: path of the jdk (c:\program files\java\jdk1,6) Variable Name: path Value: %path%;%m2_home%\bin
After setting the path go and check in the command prompt by typing mvn –version or mvn.
Step 3: Once the maven path set, then open the settings.xml and change the proxy details (in <proxy> tag).
Note: 1. Settings.xml will be available in conf folder inside maven which you downloaded
2. Proxy settings might not be required, so first try the other steps without setting the proxy details.
3. Proxy tag is commented by default. So dont forget to uncomment after entering the proxy details.
Step 4: Open the command prompt and getinto the folder where you need to create the maven structure for your project and run the
mvn archetype:generate -DgroupId=com.mycompany.app
If it ask you for any number to enter then type 255 and 5.
Once the command run then it will download the dependencies and ask the group id and artifact id (by this name only jar file will be created) then maven structure will be created in the folder from you are running the command.
Step 5: Now you need to get into the folder which you have created
source -> main -> java ->group id(which you have given) -> then here you need to put .java file (source file which need to be build) and run
mvn clean install (clean and create jar)
mvn package (its to create jar) or
mvn install(its also create the jar along with that it will put the jar in maven repository)
mvn clean ( only to clean)
here clean, install, package are keywords.
Thanks for reading this post………..!!!
532 total views, 0 views today