Spring JPetStore学习(一)配置JPetStore
来源:互联网 发布:java中的socket编程 编辑:程序博客网 时间:2024/05/16 01:17
http://quqtalk.javaeye.com/blog/362163
一、在Tomcat中部署Spring jpetstore
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目录。使用以下命令完成建表和数据导入,
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.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)修改数据库配置文件,\spring-framework-2.5.6\samples\jpetstore\war\WEB-INF目录,修改jdbc.properties,
Properties代码 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=
注意不要缺少?
(4)在\spring-framework-2.5.6\samples\jpetstore\war\WEB-INF目录web.xml中,
Xml代码 <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>
用来选择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的主页。
二、在Myeclipse上导入jpetstore
新建一工程jpetstore, 然后用..\spring-jpetstore\samples\jpetstore下的src目录复盖你的eclipse工作空间下的\jpetstore下的src目录,然后再把..\spring-jpetstore\samples\jpetstore下的war目录下的全部内容拷到你的eclipse工作空间下的\jpetstore下的WebRoot目录下复盖WEB-INF.
- Spring JPetStore学习(一)配置JPetStore
- spring-jpetstore学习之(一)jpetstore 安装篇
- spring JpetStore学习笔记(一)
- Jpetstore研究(一):spring MVC + jpetstore + mysql搭建
- 学习Spring 附带源码jpetstore 一 安装配置篇
- 学习Spring附带源码jpetstore安装配置
- spring 学习jpetstore整理(-)
- spring-jpetstore学习
- spring-jpetstore学习
- Jpetstore项目学习笔记(一)
- Jpetstore项目学习笔记(一)
- Spring JpetStore ---- log4j的配置
- spring JpetStore学习笔记(二)
- spring JpetStore学习笔记(三)
- spring JpetStore学习笔记(四)
- spring-jpetstore 学习整理(二)
- Mybatis JPetStore 学习笔记(一)
- jpetstore
- QT嵌于某个页面中的多个视频窗口如何显示全屏与恢复
- Android-checkbox实现明文显示密码
- GhostScript命令参数详解
- Android性能测试工具:Emmagee
- java.lang.OutOfMemoryError异常解决方法
- Spring JPetStore学习(一)配置JPetStore
- 96. Unique Binary Search Trees Leetcode
- SMARTFORM字符显示不完全
- N-Queens
- 【笔记】uber--子对象访问父对象的方式
- PHP读取EXCEL的方法 上
- iOS之try异常捕捉和自定义异常类的使用
- iOS 开发 高级:通过AirServer使用AirPlay镜像并实现多屏幕显示控制
- android 自定义TabHost选择器