For now I just create a simple project with the archetype: maven-archetype-webapp
My suggestion would be to use the struts2-archetype-blank
archetype instead to bootstrap your Struts 2 application. You can invoke it either from m2eclipse (via the wizards) or from the command line. For example from the command line:
mvn archetype:generate -B \
-DgroupId=tutorial \
-DartifactId=tutorial \
-DarchetypeGroupId=org.apache.struts \
-DarchetypeArtifactId=struts2-archetype-blank \
-DarchetypeVersion=2.2.1
The, add the required dependencies for Hibernate 3 and the MySQL JDBC driver. As often, there are several ways to do that:
- manually (by adding
<dependency>
elements in the pom.xml
)
- using the m2eclipse wizards
- via the dependencies tab of the pom editor
- via a right-click on your project and then Maven > Add Dependencies
- via the Eclipse quick-fix options
The Adding Dependencies Using m2eclipse blog post has a screen cast demonstrating some of them.
Whatever solution you'll choose, at the end, your pom.xml
should at least declare the following deps:
<project>
<dependencies>
...
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.2.1</version>
</dependency>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.9.0.GA</version>
</dependency>
...
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>
</dependencies>
</project>
And If you want to use the latest version of Hibernate artifacts, you'll have to add the JBoss repository under the repositories
element since they are not available in the maven central repository (sorry for making things more complicated but, well, that's how things are):
<project>
<dependencies>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.5-Final</version>
</dependency>
...
<dependencies>
...
<repositories>
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
</repositories>
...
</project>