This tutorial shows you how to create a Maven Spring/Hibernate MVC Restful Web Service using Oracle database. The project uses the Maven archetype called spring-mvc-archetype.
In Eclipse IDE (Luna SR1), click menu File > New > Maven Project (or File > New > Other > Maven Project). The New Maven Project window appears:
Click Next
Click Next. In the next screen, Select an Archetype, type spring-mvc into the Filter textbox, as shown below:
If you don’t see the spring-mvc-archetype, click the Add Archetype… button. In the Add Archetype dialog, type the following information:
· Archetype Group Id: co.ntier
· Archetype Artifact Id: spring-mvc-archetype
· Archetype Version: 1.0.2
· Repository URL: http://maven-repository.com/artifact/co.ntier/spring-mvc-archetype/1.0.2
Click OK and wait for Eclipse downloading the archetype. After you see the spring-mvc-archetype in the list. Select it and click Next. In the next window, Specify Archetype parameters, enter the following information:
· Group Id: MyMavenWS (for example)
· Artifact Id: MyMavenWS (for example)
· Version: 0.0.1-SNAPSHOT (Default)
· Package: spring.code.com (for example)
Click Finish and Eclipse will generate the project. Finally we have a project structure looks like below:
*Note: If you got below error at this point, change Repository URL to: Repository: http://repo.maven.apache.org/maven2/
Unable to create project from archetype [co.ntier:spring-mvc-archetype:1.0.2 -> http://maven-repository.com/artifact/co.ntier/spring-mvc-archetype/1.0.2]. The defined artifact is not an archetype
· Archetype Group Id: co.ntier
· Archetype Artifact Id: spring-mvc-archetype
· Archetype Version: 1.0.2
Now, it is time to run the the project. Right click on the pom.xml, and go to Run As à Run Configurations.
In the Create, mange, and run configurations screen. Double click Maven Build, and create a new configuration.
Give the configuration a Name MyMavenWS_configuration (for example)
Click Browse Workspace, select the Base Directory to be the current project (MyMavenWS).
In the Goals, enter tomcat:run
Apply and Run the configuration, you should see below server information at Console.
Open a browser, and type http://localhost:8080/MyMavenWS/, which should bring up a “Hello World!” page as seen below:












Hi. I am getting an error at both instances of the Maven repository. I have tried with both the repository URLs, but still it is unable to create the project. Can u help me?
ReplyDelete