This blog guides you through initial setup and running of maven.
Download Maven binary zip file from https://maven.apache.org/download.cgi
Download file : apache-maven-3.3.9-bin.zip
Step 2:
Extract folder and place at any location in your system. Lets suppose we store at
Step 3:
Set environment variable
Add JAVA_HOME and MAVEN_HOME. And then both home location in your path system variables.
Step 4: Now open command prompt and go to workspace and then type below command.
mvn archetype:generate -DgroupId=com.vikas -DartifactId=SimpleMavenTestStart -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Project created with all pom.xml.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vikas</groupId>
<artifactId>SimpleMavenTestStart</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>NumberGenerator</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project
Step 5: Now we can update pom.xml as per requirement of project.
Step 6: To generate jar file of project
type command: mvn package
Now under target folder SimpleMavenTestStart-1.0-SNAPSHOT.jar gets created.
Step 7: To run jar type below command
java -cp target/SimpleMavenTestStart-1.0-SNAPSHOT.jar com.vikas.App
Step 8: Now to open same project in eclipse
type: mvn eclipse:eclipse
Now, project is ready to be imported in eclipse, if required
Step 9: Now to deal with this project as maven project from inside eclipse
Select project and right click , go to Configure> Convert to Maven Project
Step 10 :Now to build or verify
Go to run as maven build> type goal as :
clean verify or
clean install
Brilliant blog I visit this blog it's incredibly awesome. Curiously, in this blog content formed doubtlessly and sensible. The substance of information is helpful.
ReplyDeleteWorkday Online Training