spring整合struts2,hibernate
1.导包
struts2包(不需要导入,之前学习struts2时已经导入)
hibernate包(不需要导入,之前学习hibernate时已经导入)
Spring包
整合hibernate的没有hibernate.cfg.xml文件
1.创建表
2.po类
所谓的javabean
数据库映射出来表
3.dao
操作数据库类
4.service
业务处理层
5.applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- 1 加载hibenrate.cfg.xml 获得SessionFactory |
测试类:
数据库结果:
2.不使用hibernate.cfg.xml文件
a.我们得知道hibernate的配置文件是干什么用的
a.1连接数据库的配置信息
a.2添加映射文件
a.3设置缓存
等其他的配置信息
所以我们得使用applicationcontext.xml来完成配置
a.1配置连接信息
a.2spring框架整合hibernate框架的工程bean
a.3注册事务管理器<必须>
a.4组件扫描(使用组件扫描会对于开发过程节约很多时间)<使用注释时才用>
a.4.1可以不使用组件扫描
自己在applicationContext.xml中编写
a.5引入注解解析器<必须>
a.6事务注解<必须>
a.7切面类<非必须>
a.8注册service<非必须>
a.1配置连接信息
<context:property-placeholder location="classpath:jdbc.properties"/> |
jdbc.properties文件
driverClass=com.mysql.jdbc.Driver |
a.2spring框架整合hibernate框架的工程bean
<!-- spring框架用于整合Hibernate的工厂bean --> </list> |
a.3注册事务管理器
<!-- 事务管理器 --> |
a.4组件扫描
<!-- 组件扫描 扫描含有注解的类 --> <context:component-scan base-package="com.itheima.bos"/> |
a.5引入注解解析器
<!-- 引入注解解析器 --> |
a.6事务注解
<!-- 事务注解 --> |
a.7切面类
<!-- 切面类 --> |
a.8注册service
<!-- 注册Service --> |
a.9其他配置
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> |
spring整合struts2,hibernate的更多相关文章
- Spring整合Struts2,Hibernate的xml方式
作为一个学习中的码农,一直学习才是我们的常态,所以最近学习了SSH(Spring,Struts2,Hibernate)整合,数据库用的MySQL. 写了一个简单的例子,用的工具是IntelliJ Id ...
- spring 整合 struts2 + Hibernate application配置文件(基于注解)
下面是 application.xml 文件. <?xml version="1.0" encoding="UTF-8"?> <beans x ...
- 一 SSH整合:Spring整合Struts2的两种方式,struts.xml管理Action&Bean管理Action
SSH回顾 1 引入jar包 Struts2的jar包 D:\Struts2\struts-2.3.35\apps\struts2-blank\WEB-INF\lib 开发基本包 Struts2有一 ...
- Struts2的使用以及Spring整合Struts2
一.如何单独使用Struts2 (1)引入struts2的jar包 commons-fileupload-1.2.1.jar freemarker-2.3.15.jar ognl-2.7.3.jar ...
- spring整合mybatis(hibernate)配置
一.Spring整合配置Mybatis spring整合mybatis可以不需要mybatis-config.xml配置文件,直接通过spring配置文件一步到位.一般需要具备如下几个基本配置. 1. ...
- Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)
1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...
- Spring整合Struts2框架的第一种方式(Action由Struts2框架来创建)。在我的上一篇博文中介绍的通过web工厂的方式获取servcie的方法因为太麻烦,所以开发的时候不会使用。
1. spring整合struts的基本操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2 ...
- Spring框架学习(5)spring整合struts2
内容源自:spring整合struts2 一.spring框架对struts等表现层框架的整合原理 : 使用spring的ioc容器管理struts中用于处理请求的Action 将Action配置成i ...
- Spring整合Struts2的方法
一.基本支持 通常我们整合Spring和struts2的目的是让Spring来管理struts2的控制器.也就是说把Action交由Spring来管理,利用IOC的特性把Action注入到业务逻辑中. ...
随机推荐
- 剑指offer 重建二叉树
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- ubuntu 14.0.4下安装有道字典
一,下载安装包地址:http://codown.youdao.com/cidian/linux/youdao-dict_1.0.2~ubuntu_i386.deb http://codown.youd ...
- 任意2个io直接驱动LCD1602,并且不需外加芯片(转)
http://www.amobbs.com/thread-4301955-1-1.html *此处只摘录部分内容,详细内容请关注原贴. 这就是电路,细心的朋友会发现实物图中有几个贴片的阻容件,秘密就在 ...
- 判断非法字符串的类方法,与jsp
private String_do_judge judge; if (judge.isContain(key)) { return "feifa"; } 上面这写代码添加到进入ac ...
- They Are Everywhere
They Are Everywhere Sergei B., the young coach of Pokemons, has found the big house which consists o ...
- javascript的 replace() 方法的使用讲解
String.prototype.replace() The replace() method returns a new string with some or all matches of a p ...
- VPN工作原理
引言 在过去几十年中,世界发生了很大的变化.现在很多公司除了处理本地或地区性事务外,还要考虑全球市场和物流的问题.很多公司在全国甚至全球都设有分支机构,而这些公司都需要做的一件事情就是:找到能够与分公 ...
- LVS详解
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...
- hearbeart
Heartbeat(Linux-HA工程的一个组件) Heartbeat 项目是 Linux-HA 工程的一个组成部分,它实现了一个高可用集群系统.心跳服务和集群通信是高可用集群的两个关键组件,在 H ...
- iOS 的三种自建证书方法https请求相关配置
如果你的app服务端安装的是SLL颁发的CA,可以使用系统方法直接实现信任SSL证书,关于Apple对SSL证书的要求请参考:苹果官方文档CertKeyTrustProgGuide 这种方式不需要在B ...