The application developed in this tutorial is based on the petclinic-sample of the Spring Framework. Please download spring-framework-3.0.6-with-docs.zipfrom here. This tutorial was written with the sample delivered with version 3.0.6 of the Spring Framework and may or may not work with other versions. In the zip-file within the base-folder spring-framework-2.5.6/ you find a folder named samples. Within that folder there is a folder named petclinic. Please unpack this folder. It is the only folder we need from that zip.
Like in the simple-tutorial we want to use maven 3 to build and deploy our application. So the first step is to put a pom.xml file into the folder petclinic with the following content.
As a sidenote it is important to notice that in previous version the specific versions of dependencies like the spring-framework were written in the pom.xml. During the transition to version 3.0.x of spring jpasecurity was modularized and all versions are now specified in /jpasecurity-parent/pom.xml.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>net.sf.jpasecurity</groupId>
<artifactId>jpasecurity-parent</artifactId>
<version>0.4.0</version>
<relativePath>../../jpasecurity-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jpasecurity-spring-petclinic-sample</artifactId>
<packaging>war</packaging>
<name>JPA Security Spring Petclinic Sample</name>
<url>http://jpasecurity.sf.net</url>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<configuration>
<tasks>
<java classname="org.apache.openjpa.enhance.PCEnhancer"
classpathref="maven.runtime.classpath"
dir="target/classes" fork="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<stopKey>petclinic</stopKey>
<stopPort>1199</stopPort>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>EclipseLink Repo</id>
<url>http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jpasecurity-spring</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
</dependencies>
</project>
To be conform with maven, we have to change the directory-structure:
We don't need the rest of the content of the folder db/, so you may safely delete it. The same applies to the folder test/ and the ant build-files (namely build.bat, build.properties, build.xml and warfile.bat).