Still on the Java EE 7 hype, here’s a quick cheat sheet on how to create a minimal Java EE 7 ready maven project:
Ensure you have Eclipse Indigo installed with m2e (maven connector). If not you can drag and drop this logo into running Eclipse instance (thanks m2e team)
Create new maven project, tick Create a simple project (skip archetype selection), on the next screen provide Group Id, Artifact Id, and set Packaging to war. Hit Finish
Open pom.xml, switch to source view. Add Java EE 7 dependency. Set the scope to provided so that it is included at compile time, but not on the war bundle (because it should be provided by container)
Tell Maven to compile using JDK 7, otherwise the deafault is JDK 5
maven-compiler-plugin3.11.71.7
And finally prevent maven-war-plugin from complaining because of missing web.xml. New Java EE 7 style provides good annotation support, web.xml can be omitted for a simple project
maven-war-plugin2.3false
Right click on the project -> Maven -> Update Project… -> OK. This will cause m2e to synchronize with all changes we made
Test your new project by running clean package
You should end up with a war bundle with your project name under target directory
5 thoughts on “Creating New Java EE 7 Maven Eclipse Project”
Beautiful, I got everything working using this tutorial, also you might mention that cleaning the maven “.m2″ repo might resolve any build issues.
Thanks. The internal maven repository causes problem if you manually insert artifacts into it / there are corrupt files. As long as you’re managing it properly you should never have to delete it.
Thanks, very helpfull.
Reply
Many thanks for this tutorial. I could create the maven project but I can not find how to run “clean package”.Would you say in which Eclipse menu or option I can run maven goals?
Reply
You need to either intstall the maven plugin for eclipse (m2e) and setup a Maven run configuration, or run the maven command line. It might help to spend some time with the maven documentation.
Beautiful, I got everything working using this tutorial, also you might mention that cleaning the maven “.m2″ repo might resolve any build issues.
Thanks. The internal maven repository causes problem if you manually insert artifacts into it / there are corrupt files. As long as you’re managing it properly you should never have to delete it.
Thanks, very helpfull.
Many thanks for this tutorial. I could create the maven project but I can not find how to run “clean package”.Would you say in which Eclipse menu or option I can run maven goals?
You need to either intstall the maven plugin for eclipse (m2e) and setup a Maven run configuration, or run the maven command line. It might help to spend some time with the maven documentation.