[SPR-6222] Updating PetClinic build documentation regarding migration to Spring Build and changes resulting from the upgrade to Spring 3.0.

This commit is contained in:
Sam Brannen 2009-10-11 18:08:44 +00:00
parent 0b069ebe46
commit f57d702370
3 changed files with 46 additions and 79 deletions

View File

@ -6,7 +6,7 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1) Download and install the MySQL database (e.g., MySQL Community Server 5.0.x), 1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x),
which can be found here: http://dev.mysql.com/downloads/ which can be found here: http://dev.mysql.com/downloads/
2) Download Connector/J, the MySQL JDBC driver (e.g., Connector/J 5.1.x), which 2) Download Connector/J, the MySQL JDBC driver (e.g., Connector/J 5.1.x), which

View File

@ -59,10 +59,10 @@ Available build commands:
- ant clean jar --> cleans the project and builds the WAR - ant clean jar --> cleans the project and builds the WAR
After building the project with "ant clean jar", you will find the After building the project with "ant clean jar", you will find the
resulting WAR file in the "target" directory. By default, an embedded resulting WAR file in the "target/artifacts" directory. By default, an
HSQLDB instance in configured. No other steps are necessary to get the embedded HSQLDB instance in configured. No other steps are necessary to
data source up and running: you can simply deploy the built WAR file get the data source up and running: you can simply deploy the built WAR
directly to your Servlet container. file directly to your Servlet container.
For MySQL, you'll need to use the corresponding schema and SQL scripts in For MySQL, you'll need to use the corresponding schema and SQL scripts in
the "db/mysql" subdirectory. Follow the steps outlined in the "db/mysql" subdirectory. Follow the steps outlined in

View File

@ -13,7 +13,8 @@
<h1>The Spring PetClinic Application</h1> <h1>The Spring PetClinic Application</h1>
<table class="updated"> <table class="updated">
<tr><td>Updated:</td><td>21.OCT.2007</td><td>Sam Brannen</td></tr> <tr><td>Updated:</td><td>11.OCT.2009</td><td>Sam Brannen (<strong>Work In Progress: not yet fully updated regarding Spring 3.0</strong>)</td></tr>
<tr><td></td><td>21.OCT.2007</td><td>Sam Brannen</td></tr>
<tr><td></td><td>30.JUN.2006</td><td>Costin Leau</td></tr> <tr><td></td><td>30.JUN.2006</td><td>Costin Leau</td></tr>
<tr><td></td><td>01.DEC.2004</td><td>Ken Krebs</td></tr> <tr><td></td><td>01.DEC.2004</td><td>Ken Krebs</td></tr>
<tr><td></td><td>16.AUG.2003</td><td>Ken Krebs</td></tr> <tr><td></td><td>16.AUG.2003</td><td>Ken Krebs</td></tr>
@ -134,7 +135,7 @@
specifically for Apache Tomcat. These files specify container-supplied specifically for Apache Tomcat. These files specify container-supplied
connection-pooled data sources. It is not necessary to use these files. connection-pooled data sources. It is not necessary to use these files.
The application has been configured by default to use a data source The application has been configured by default to use a data source
without connection pooling to simplify usage. Configuration details are with connection pooling. Configuration details are
provided in the Developer Instructions section. The view technologies provided in the Developer Instructions section. The view technologies
that are to be used for rendering the application are Java Server Pages that are to be used for rendering the application are Java Server Pages
(JSP) along with the Java Standard Tag Library (JSTL). (JSP) along with the Java Standard Tag Library (JSTL).
@ -145,7 +146,7 @@
The sample application uses a relational database for data storage. The sample application uses a relational database for data storage.
Support has been provided for a choice of 1 of 2 database selections, Support has been provided for a choice of 1 of 2 database selections,
MySql or HypersonicSQL. HypersonicSQL version 1.8.0 is the default MySql or HypersonicSQL. HypersonicSQL version 1.8.0 is the default
choice and a copy is provided with the application. It is possible to choice. It is possible to
easily configure the application to use either database. Configuration easily configure the application to use either database. Configuration
details are provided in the Developer Instructions section. details are provided in the Developer Instructions section.
</p> </p>
@ -161,8 +162,7 @@
<ul> <ul>
<li>Java SDK 1.5.x</li> <li>Java SDK 1.5.x</li>
<li>Ant 1.7.x</li> <li>Ant 1.7.x</li>
<li>Tomcat 5.x.x, or some other web application container</li> <li>Tomcat 6.x.x, or some other Java Servlet container</li>
<li>JUnit 4.4 - needed to run the tests</li>
<li>(Optional) MySQL 5.x with MySQL Connector/J 5.x</li> <li>(Optional) MySQL 5.x with MySQL Connector/J 5.x</li>
</ul> </ul>
@ -310,10 +310,10 @@
<p> <p>
Spring supports the use of the Apache Commons Logging API. This API Spring supports the use of the Apache Commons Logging API. This API
provides the ability to use Java 1.4 loggers, the simple Commons loggers, provides the ability to use Java 1.4 loggers, the simple Commons loggers,
and Apache Log4J loggers. PetClinic uses Log4J to provide sophisticated and Apache log4j loggers. PetClinic uses log4j to provide sophisticated
and configurable logging capabilities. The file, and configurable logging capabilities. The file,
<span style="font-weight: bold; font-style: italic;">war/WEB-INF/log4j.properties</span> <span style="font-weight: bold; font-style: italic;">src/main/resources/log4j.properties</span>
configures the definition of <strong>Log4j</strong>loggers. configures the definition of <strong>log4j</strong>loggers.
</p> </p>
<h3>Business Layer</h3> <h3>Business Layer</h3>
@ -503,7 +503,7 @@
<span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.hibernate.HibernateClinic</span>. <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.hibernate.HibernateClinic</span>.
To simplify using Hibernate, Spring provides the To simplify using Hibernate, Spring provides the
<span style="font-weight: bold;">org.springframework.orm.hibernate3.LocalSessionFactoryBean</span>. <span style="font-weight: bold;">org.springframework.orm.hibernate3.LocalSessionFactoryBean</span>.
The Hibernate configuration is provided by the file <span style="font-style: italic;">src/petclinic.hbm.xml</span>. The Hibernate configuration is provided by the file <span style="font-style: italic;">src/main/resources/petclinic.hbm.xml</span>.
</p> </p>
<h3>Java Persistence API (JPA) Clinic Implementation</h3> <h3>Java Persistence API (JPA) Clinic Implementation</h3>
@ -518,8 +518,8 @@
To simplify JPA usage, Spring provides (among other classes) the To simplify JPA usage, Spring provides (among other classes) the
<span style="font-weight: bold;">org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean</span>. <span style="font-weight: bold;">org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean</span>.
The JPA configuration is provided by The JPA configuration is provided by
<span style="font-style: italic;">src/META-INF/orm.xml</span> and <span style="font-style: italic;">src/main/resources/META-INF/orm.xml</span> and
<span style="font-style: italic;"> src/META-INF/persistence.xml.</span> <span style="font-style: italic;"> src/main/resources/META-INF/persistence.xml.</span>
</p> </p>
<h3>ApplicationContext</h3> <h3>ApplicationContext</h3>
@ -530,7 +530,7 @@
constitute the <span style="font-weight: bold;">Business/Persistence constitute the <span style="font-weight: bold;">Business/Persistence
Layer</span> of PetClinic. The following beans are defined in all 3 Layer</span> of PetClinic. The following beans are defined in all 3
versions (1 per access strategy) of the PetClinic versions (1 per access strategy) of the PetClinic
<span style="font-style: italic;">war/WEB-INF/applicationContext-*.xml</span> <span style="font-style: italic;">src/main/webapp/WEB-INF/applicationContext-*.xml</span>
file: file:
</p> </p>
@ -542,7 +542,7 @@
properties file, in this case, JDBC-related settings for the properties file, in this case, JDBC-related settings for the
<span style="font-weight: bold; font-style: italic;">dataSource</span> bean <span style="font-weight: bold; font-style: italic;">dataSource</span> bean
described below described below
(see <span style="font-weight: bold; font-style: italic;">src/jdbc.properties</span>). (see <span style="font-weight: bold; font-style: italic;">src/main/resources/jdbc.properties</span>).
</li> </li>
<li><span style="font-weight: bold; font-style: italic;">dataSource</span>, <li><span style="font-weight: bold; font-style: italic;">dataSource</span>,
which is a singleton bean that defines the implementation of the source which is a singleton bean that defines the implementation of the source
@ -571,14 +571,14 @@
</p> </p>
<ul> <ul>
<li><span style="font-weight: bold; font-style: italic;">war/WEB-INF/web.xml</span>: <li><span style="font-weight: bold; font-style: italic;">src/main/webapp/WEB-INF/web.xml</span>:
the web application configuration file.</li> the web application configuration file.</li>
<li><span style="font-weight: bold; font-style: italic;">war/WEB-INF/petclinic-servlet.xml</span>: <li><span style="font-weight: bold; font-style: italic;">src/main/webapp/WEB-INF/petclinic-servlet.xml</span>:
configures the petclinic dispatcher servlet and the other controllers configures the petclinic dispatcher servlet and the other controllers
and forms that it uses. The beans defined in this file reference the and forms that it uses. The beans defined in this file reference the
Business/Persistence Layer beans defined in Business/Persistence Layer beans defined in
<span style="font-style: italic;">applicationContext-*.xml.</span></li> <span style="font-style: italic;">applicationContext-*.xml.</span></li>
<li><span style="font-weight: bold; font-style: italic;">war/WEB-INF/classes/messages*.properties</span>: <li><span style="font-weight: bold; font-style: italic;">src/main/resources/messages*.properties</span>:
configures the definition of internationalizable message resources.</li> configures the definition of internationalizable message resources.</li>
</ul> </ul>
@ -652,15 +652,15 @@
<li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>, <li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>,
a <span style="font-weight: bold;">"log4jConfigLocation"</span> context-param a <span style="font-weight: bold;">"log4jConfigLocation"</span> context-param
is specified that sets the location of the is specified that sets the location of the
<span style="font-weight: bold;">Log4j</span> configuration file. The <span style="font-weight: bold;">log4j</span> configuration file. The
default location for this file is default location for this file is
<span style="font-weight: bold; font-style: italic;">/WEB-INF/classes/log4j.properties</span>. <span style="font-weight: bold; font-style: italic;">/WEB-INF/classes/log4j.properties</span>.
Specifying this parameter explicitly allows the location to be changed Specifying this parameter explicitly allows the location to be changed
from the default and is also used to cause periodic from the default and is also used to cause periodic
<span style="font-weight: bold;">Log4j</span> configuration refresh checks.</li> <span style="font-weight: bold;">log4j</span> configuration refresh checks.</li>
<li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>, <li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>,
a <span style="font-weight: bold;">Log4jConfigListener</span> is a <span style="font-weight: bold;">Log4jConfigListener</span> is
specified that will initialize <span style="font-weight: bold;">Log4j</span> using specified that will initialize <span style="font-weight: bold;">log4j</span> using
the specified configuration file when the web app starts. The the specified configuration file when the web app starts. The
<span style="font-weight: bold;">Log4jConfigListener</span> is commented out <span style="font-weight: bold;">Log4jConfigListener</span> is commented out
in the file because of a conflict when using JBoss. It should also be in the file because of a conflict when using JBoss. It should also be
@ -897,7 +897,7 @@
which displays a stack trace and normally wouldn't be used in a production which displays a stack trace and normally wouldn't be used in a production
version of an application. It can be seen in action by entering a URL of version of an application. It can be seen in action by entering a URL of
"editOwner.do" or "editPet.do" with an invalid request parameter, for example: "editOwner.do" or "editPet.do" with an invalid request parameter, for example:
<a href="http://localhost:8080/petclinic/owner.do?ownerId=-1">/petclinic/owner.do?ownerId=-1</a>. <a href="http://localhost:8080/org.springframework.samples.petclinic/owner.do?ownerId=-1">/petclinic/owner.do?ownerId=-1</a>.
The handlers for these URLs normally expect to see a respective "ownerId" or "petId" The handlers for these URLs normally expect to see a respective "ownerId" or "petId"
request parameter corresponding to an Owner or Pet in the database. Thus, request parameter corresponding to an Owner or Pet in the database. Thus,
these handlers will throw a <strong>DataAccessException</strong> when such these handlers will throw a <strong>DataAccessException</strong> when such
@ -908,7 +908,7 @@
in a production version of an application. It can be seen in action by in a production version of an application. It can be seen in action by
entering a URL of "editOwner.do" or "editPet.do" without a valid request entering a URL of "editOwner.do" or "editPet.do" without a valid request
parameter, for example: parameter, for example:
<a href="http://localhost:8080/petclinic/owner.do">/petclinic/owner.do</a>. <a href="http://localhost:8080/org.springframework.samples.petclinic/owner.do">/petclinic/owner.do</a>.
The handlers for these URLs normally expect to see a respective "ownerId" or "petId" The handlers for these URLs normally expect to see a respective "ownerId" or "petId"
request parameter and throw a <strong>ServletException</strong> when such request parameter and throw a <strong>ServletException</strong> when such
a request parameter is not found.</li> a request parameter is not found.</li>
@ -1025,60 +1025,28 @@
<h3>Downloads</h3> <h3>Downloads</h3>
<ul> <ul>
<li>Download and install the <li>Download and install the
<a href="http://sourceforge.net/projects/springframework/" target="_blank">Spring Framework</a> <a href="http://www.springsource.com/download/community?project=Spring%20Framework" target="_blank">Spring Framework</a>
(examples, including PetClinic are provided)</li> (the PetClinic sample application is included)</li>
<li>Download and install a <a href="http://java.sun.com/" target="_blank">Java</a> <li>Download and install a <a href="http://java.sun.com/" target="_blank">Java</a>
Software Developer Kit, version 1.5 or later</li> Software Developer Kit, version 1.5 or later</li>
<li>Download and install <a href="http://ant.apache.org" target="_blank">Apache Ant</a>, <li>Download and install <a href="http://ant.apache.org" target="_blank">Apache Ant</a>,
preferably version 1.7.0 or later</li> preferably version 1.7.0 or later</li>
<li>Download and install <a href="http://www.junit.org/" target="_blank">JUnit</a>,
preferably version 4.4 or later</li>
<li>Download and install <a href="http://jakarta.apache.org/tomcat/index.html" target="_blank">Apache Tomcat</a>, <li>Download and install <a href="http://jakarta.apache.org/tomcat/index.html" target="_blank">Apache Tomcat</a>,
preferably version 5.5.x or later</li> preferably version 6.0.18 or later</li>
<li>Download and install <a href="http://www.mysql.com/" target="_blank">MySQL</a>, <li>Download and install <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a>,
preferably version 5.0.x or later (optional)</li> preferably version 5.1.x or later (optional)</li>
<li><a href="http://hsqldb.sourceforge.net/" target="_blank">Hypersonic SQL</a>, and <li><a href="http://hsqldb.sourceforge.net/" target="_blank">Hypersonic SQL</a>, and
<a href="http://hibernate.org/" target="_blank">Hibernate</a> are provided with the <a href="http://hibernate.org/" target="_blank">Hibernate</a> are provided with the
application.</li> application.</li>
<li>PetClinic and Spring use the <a href="http://www.apache.org/" target="_blank">Apache</a> <li>PetClinic and Spring use the <a href="http://www.apache.org/" target="_blank">Apache</a>
<a href="http://jakarta.apache.org/commons/logging/" target="_blank">Commons Logging</a> <a href="http://commons.apache.org/logging/" target="_blank">Commons Logging</a>
and <a href="http://jakarta.apache.org/log4j/docs/index.html" target="_blank">Log4J</a> and <a href="http://logging.apache.org/log4j/1.2/apidocs/index.html" target="_blank">log4j</a>
packages</li> packages.</li>
</ul> </ul>
<h3>Ant Setup</h3> <h3>Ant Setup</h3>
<p> <p>
Make sure that the Ant executable is in your command shell path. Ant Make sure that the Ant executable is in your command shell path.
will need to reference classes from <span style="font-weight: bold;">JUnit</span>
and the database(s) of interest. Place a copy of any needed jar files in
Ant's <span style="font-weight: bold; font-style: italic;">/lib</span> directory, i.e.:
</p>
<ul>
<li>JUnit - <span style="font-weight: bold; font-style: italic;">junit.jar</span></li>
<li>HSQL - <span style="font-weight: bold; font-style: italic;">hsqldb.jar</span></li>
<li>MYSQL - <span style="font-weight: bold; font-style: italic;">mysql-connector-java-5.1.5-bin.jar</span> or other</li>
</ul>
<h3>HSQL Setup</h3>
<p>
Create a new directory containing a copy of the entire contents of
the directory <span style="font-weight: bold; font-style: italic;">petclinic/db/hsqldb</span>.
The file <span style="font-weight: bold; font-style: italic;">petclinic.script</span>
is the data file that will be used by the server. It has been
initialized with some sample data. Start a server on the standard port
by executing <span style="font-weight: bold; font-style: italic;">server.sh</span>(Unix)
or <span style="font-weight: bold; font-style: italic;">server.bat</span> (Windows)
or alternatively edit the file to select a port of your choosing.
A useful database manager can be started by executing
<span style="font-weight: bold; font-style: italic;">manager.sh</span> (Unix)
or <span style="font-weight: bold; font-style: italic;">manager.bat</span> (Windows).
When the application opens, connect to the "HSQL Database Engine
Server" using the default parameters. This tool can also be used to
manage other databases. To use a different port, it will be necessary
to change the PetClinic Database Setup. It may also be necessary to
consult the HSQL documentation for instructions on how to change the port
the server uses.
</p> </p>
<h3>MYSQL Setup (optional)</h3> <h3>MYSQL Setup (optional)</h3>
@ -1126,15 +1094,15 @@
separate log file for the petclinic context. This will separate the separate log file for the petclinic context. This will separate the
container logging for petclinic from that of the other webapps. This container logging for petclinic from that of the other webapps. This
should not be confused with the application log file provided through should not be confused with the application log file provided through
<span style="font-weight: bold;">Log4j.</span></li> <span style="font-weight: bold;">log4j.</span></li>
<li>An Ant script (<span style="font-weight: bold; font-style: italic;">db/build.xml</span>) <li>An Ant script (<span style="font-weight: bold; font-style: italic;">db/build.xml</span>)
has been provided that can be used to re-initialize either database. To has been provided that can be used to re-initialize either database. To
select or configure the data source and database used for the webapp and select or configure the data source and database used for the webapp and
for testing, you will need to edit the following files: for testing, you will need to edit the following files:
<ul> <ul>
<li><span style="font-weight: bold; font-style: italic;">war/WEB-INF/applicationContext-*.xml</span>: <li><span style="font-weight: bold; font-style: italic;">src/main/webapp/WEB-INF/applicationContext-*.xml</span>:
for configuring the DataSource in the webapp</li> for configuring the DataSource in the webapp</li>
<li><span style="font-weight: bold; font-style: italic;">src/jdbc.properties</span>: <li><span style="font-weight: bold; font-style: italic;">src/main/resources/jdbc.properties</span>:
for configuring JDBC connection settings for both the webapp and testing</li> for configuring JDBC connection settings for both the webapp and testing</li>
<li><span style="font-weight: bold; font-style: italic;">build.properties</span>: <li><span style="font-weight: bold; font-style: italic;">build.properties</span>:
for running the &quot;tests&quot; target in Ant</li> for running the &quot;tests&quot; target in Ant</li>
@ -1145,12 +1113,11 @@
<h3>Building the PetClinic Application</h3> <h3>Building the PetClinic Application</h3>
<p> <p>
Open a command line shell and navigate to the directory containing Open a command line shell and navigate to the directory containing
PetClinic and execute &quot;ant&quot;. This will display a list of the Ant PetClinic and execute &quot;ant -p&quot;. This will display a list of the Ant
targets that are available. Make sure the database is running and execute targets that are available. Make sure the database is running and execute
&quot;ant all&quot;. This will run the Ant &quot;all&quot; target which &quot;ant clean test&quot;. This will run clean and compile everything
will clean and compile everything, generate Javadoc, and execute the tests, and execute the tests, including integration tests against an in-memory
including a live test using the database. The other Ant targets provide database.
subsets of this functionality.
</p> </p>
<h3>Deploying the PetClinic Application</h3> <h3>Deploying the PetClinic Application</h3>
@ -1158,16 +1125,16 @@
Deploy the web application to the server in the usual way (see Deploy the web application to the server in the usual way (see
<a href="#dbNotes">notes</a> regarding database setup). If you need <a href="#dbNotes">notes</a> regarding database setup). If you need
instructions for web application deployment, see the Tomcat instructions for web application deployment, see the Tomcat
documentation for details. The Web ARchive file is documentation for details. The Web Application aRrchive file is
<span style="font-weight: bold; font-style: italic;">petclinic.war</span> <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.war</span>
and can be found in the and can be found in the
<span style="font-weight: bold; font-style: italic;">dist</span> directory. <span style="font-weight: bold; font-style: italic;">target/artifacts</span> directory.
</p> </p>
<h3>Using the PetClinic Application</h3> <h3>Using the PetClinic Application</h3>
<p> <p>
Make sure the PetClinic web application is running and browse to Make sure the PetClinic web application is running and browse to
<a href="http://localhost:8080/petclinic">http://localhost:8080/petclinic</a>. <a href="http://localhost:8080/org.springframework.samples.petclinic/">http://localhost:8080/org.springframework.samples.petclinic/</a>.
</p> </p>
<table class="footer"> <table class="footer">