URL:
http://www.yiibai.com/maven/create-a-java-project-with-maven.html
mvn archetype:generate -DgroupId=com.yiibai -DartifactId=NumberGenerat or -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
mvn eclipse:eclipse
mvn package -DskipTests java -cp target/NumberGenerator-1.0-SNAPSHOT.jar com.yiibai.App
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.yiibai</groupId> <artifactId>NumberGenerator</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> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
package com.yiibai; import java.util.UUID; /** * Generate a unique number * */ public class App { public static void main( String[] args ) { App obj = new App(); System.out.println("Unique ID : " + obj.generateUniqueKey()); } public String generateUniqueKey(){ String id = UUID.randomUUID().toString(); return id; } }