Java project with maven. Spring.

Spring Maven project. STS


Make Maven Project

 
Look at the picture. File - New - Maven Project

Setting Id with version

 
If you select Maven Project, you just choice 'Next' until this window. here Group Id means your company Id (commonly use 'com.meansoup'), Artifact Id is for your project name. Version is for managing project version. you can see your package name same with ID and version linked.
what you name Id or version doesn't matter when program running.

Running by STS

 
It is easy to running project at STS. you just push 'run' button, you can see result at console.

Make distribution File with Maven

 
Running by STS is easy. But our goal is using Maven. for making distribution file, first, you select your maven project. next choose Run As - Maven Install.
now, your distribution file is made.

distribution file location

 
you can see your distribution file at 'project'/target. this jar file's name is made by connecting Artifact Id with version.

no main manifest attribute, in .jar

 
You can run your jar file with 'java -jar "filename"'
But, you will encounter no main manifest attribute, in .jar now we push manifest.

maven-jar-plugin add

 
We can solve manifest problem by adding plugin. open your pom.xml file at your Maven project. add maven-jar-plugin. You can make manifest.mf
[notice] you must edit your mainClass.
                 <plugin>
                        <groupId>org.apache.maven.plugins</groupId>  
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>2.6</version>
                        <configuration>  
                           <archive>
<manifest>
                                 <mainClass>meansoup.practice.App</mainClass>  
                               </manifest>  
                           </archive>  
                       </configuration>
                 </plugin>

run jar file

 
now you can run your jar file with no error

Previous
Next Post »