Create a Quick Java Project with Maven
Prerequisites :
- Java version 6 +
- Check this with "java -version" command.
- Maven - Maven is a java tool so have this installed after java is installed.
- mvn --version
Creating a Project :
mvn archetype:generate -DgroupId=com.fileupload-DartifactId=upload-fileto-s3-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The pom file is the core of the project configuration in maven. It contains all necessary information to build the project.
Build the project :
mvn package - Mvn will compile and package the project into a jar file.
mvn clean install - this will clean the artifacts build by earlier builds.
To use eclipse and make this project an eclipse project :
mvn eclipse:eclipse
Run the application from eclipse and you will see the following output.
Creating a fat jar :
Fat jar is a jar with all executables and dependencies.
You can use a plugin maven-shade-plugin plugin for this.
Specify the main class
<mainClass>com.fileupload.App</mainClass>
Also, specify the name of your jar
<finalName>uploadTos3</finalName>
Package it
$ mvn package
Run the jar as below :
java -jar target/uploadTos3.jar
Comments
Post a Comment