Http://quqtalk.javaeye.com/blog/362163
1. Deploying spring jpetstore in Tomcat
Jpetstore in spring samples is based on ibatis jpetstore, and ibatis is used at the database layer. On the web layer, two MVC options are available: Spring MVC and Struts MVC (1.1 ).
Test environment:
JDK version: 1.5.0 _ 12-b04
Tomcat version: 6.0.18
Spring version: 2.5.6
MySQL version: 5.1.32
(1) go to the spring website to obtain the installation media for the jpetstore example. Go to download center at http://www.springsource.org/and select 2.5.6-with-dependencies to download.
(2) decompress the downloaded zip package. The jpetstore example is in the \ spring-framework-2.5.6 \ samples \ jpetstore directory.
(3) create a jpetstore database table in the MySQL database and import some initial data. The SQL statement for table creation and data import is in the \ spring-framework-2.5.6 \ samples \ jpetstore \ dB \ mysql directory. Run the following command to create a table and import data,
SQLCode
- Mysql-H 127.0.0.1-u root-P
- Create Database jpetstore;
- Use jpetstore;
- Source \ spring-framework-2.5.6 \ samples \ jpetstore \ dB \ mysql \ jpetstore-mysql-schema. SQL
- Source \ spring-framework-2.5.6 \ samples \ jpetstore \ dB \ mysql \ jpetstore-mysql-dataload. SQL
Mysql-H 127.0.0.1-u root-p create database jpetstore; Use jpetstore; source \ spring-framework-2.5.6 \ samples \ jpetstore \ dB \ mysql \ jpetstore-mysql-schema.sqlsource \ spring-framework-2.5.6 \ samples \ jpetstore \ dB \ mysql \ jpetstore-mysql-dataload. SQL
(3) modify the database configuration file, \ spring-framework-2.5.6 \ samples \ jpetstore \ war \ WEB-INF directory, modify JDBC. properties,
Properties code JDBC. driverclassname = com. MySQL. JDBC. Driver JDBC. url = JDBC: mysql:// 127.0.0.1: 3306/jpetstore?JDBC. Username = root JDBC. Password = JDBC. driverclassname = com. MySQL. JDBC. driverjdbc. url = JDBC: mysql:// 127.0.0.1: 3306/jpetstore?JDBC. Username = rootjdbc. Password =
Do not missing?
(4) In the \ spring-framework-2.5.6 \ samples \ jpetstore \ war \ WEB-INF Directory web. XML,
XML Code < Servlet - Mapping > < Servlet - Name > PetStore</ Servlet -Name > <! -- <Servlet-Name> action </servlet-Name> --> < URL - Pattern > *. Do </ URL -Pattern > </ Servlet -Mapping > < Servlet - Mapping > < Servlet - Name > PetStore </ Servlet -Name > <! -- <Servlet-Name> action </servlet-Name> --> < URL - Pattern > *. Do</ URL -Pattern > </ Servlet -Mapping >
Use spring or struts for MVC. PetStore indicates spring and action indicates struts.
(5) After the configuration file is modified, run the warfile command in the \ spring-framework-2.5.6 \ samples \ jpetstore directory. bat, jpetstore is created in the DIST directory. war package. Copy the war package to the webapps directory of Tomcat.
(6) start Tomcat and enter http: // 127.0.0.1: 8080/jpetstore in the browser to view the jpetstore homepage.
2. Import jpetstore on myeclipse
Create a project jpetstore, and then use .. the src directory under \ spring-jpetstore \ samples \ jpetstore overwrites the src directory under \ jpetstore in your eclipse workspace .. \ spring-jpetstore \ samples \ All contents under the war directory under the jpetstore copy to your eclipse workspace under the \ jpetstore webroot directory to overwrite WEB-INF.