首页 技术 正文
技术 2022年11月14日
0 收藏 569 点赞 4,856 浏览 1412 个字

第三篇:在Tomcat中部署Spring jpetstore

博客分类:

SpringTomcatMySQLJDBCMVC 

Spring samples中的jpetstore,基于iBATIS的jpetstore,数据库层使用iBATIS。在web层,提供了两种MVC可以选择,即Spring的MVC和Struts的MVC(1.1)。

测试环境:

JDK版本:1.5.0_12-b04

Tomcat版本:6.0.18

Spring版本:2.5.6

MySQL版本:5.1.32

(1)到Spring网站获取jpetstore例子的安装介质。到http://www.springsource.org/的download center,选择2.5.6-with-dependencies下载。

(2)解压下载的zip包,jpetstore例子在\spring-framework-2.5.6\samples\jpetstore目录。

(3)在MySQL库中创建jpetstore运行需要的数据库表,并导入一些初始数据。建表和导入数据的SQL语句在\spring-framework-2.5.6\samples\jpetstore\db\mysql目录。使用以下命令完成建表和数据导入,

  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

(3)修改数据库配置文件,\spring-framework-2.5.6\samples\jpetstore\war\WEB-INF目录,修改jdbc.properties,

  1. jdbc.driverClassName=com.mysql.jdbc.Driver
  2. /jpetstore?
  3. jdbc.username=root
  4. jdbc.password=

(4)在\spring-framework-2.5.6\samples\jpetstore\war\WEB-INF目录web.xml中,

  1. <servlet-mapping>
  2. <servlet-name>petstore</servlet-name>
  3. <!–
  4. <servlet-name>action</servlet-name>
  5. –>
  6. <url-pattern>*.do</url-pattern>
  7. </servlet-mapping>

用来选择MVC是用Spring还是Struts,petstore代表使用Spring,action代表使用Struts。

(5)修改完配置文件后,\spring-framework-2.5.6\samples\jpetstore目录,运行warfile.bat,会在dist目录中创建jpetstore.war包,将此war包copy到Tomcat的webapps目录。

(6)启动Tomcat,在浏览器中输入http://127.0.0.1:8080/jpetstore,就可以看到jpetstore的主页。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,498
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,911
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,745
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,502
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,141
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,304