Spring jpetstore (1) Configure jpetstore

Source: Internet
Author: User

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

    1. Mysql-H 127.0.0.1-u root-P
    2. Create Database jpetstore;
    3. Use jpetstore;
    4. Source \ spring-framework-2.5.6 \ samples \ jpetstore \ dB \ mysql \ jpetstore-mysql-schema. SQL
    5. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.