下面是 application.xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
">
<!-- 上面的开启了
aop命名空间
tx命名空间
context命名空间
--> <!-- 开启注解开发spring模式 -->
<context:component-scan base-package="cn.itcast"/> <!-- hibernateTemplate,用于提供dao层的各种操作 -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<!--
注入SessionFactory,虽然HibernateTemplate类中没有对应的sessionFactory属性,
但是其父类HibernateAccessor有
-->
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!--
sessionFactory的bean,这里使用的sessionFactory不再是SessionFactoryBean了,
而是它的子类AnnotationSessionFactoryBean,专门用于注解的sessionFactorybean
-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<!-- 注入dataSource数据源 -->
<property name="dataSource" ref="dataSource"/>
<!-- 注入Hibernate的各种属性 -->
<property name="hibernateProperties">
<props>
<!-- 数据库方言的设置,必须设置,用于生成正确的sql语句 -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop><!-- 展示sql,非必须,开发使用 -->
<prop key="hibernate.format_sql">true</prop><!-- 格式化sql,非必须,开发使用 -->
</props>
</property>
<!--
资源注册,和之前的不一样了,因为采用了注解模式,没有了xxxhbm.xml文件了,不能像之前那样注册了。
采用的是包扫描
-->
<property name="packagesToScan">
<list>
<!-- 这里使用的package,不是路径,所以使用的是点,而不是斜杠 -->
<value>cn.itcast.ssh.annotation.user.vo</value>
</list>
</property>
</bean> <!-- dataSource,配置数据源,包括驱动,url,用户名,密码 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/DB_Demo1"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
</beans>

spring 整合 struts2 + Hibernate application配置文件(基于注解)的更多相关文章

  1. Spring整合Struts2,Hibernate的xml方式

    作为一个学习中的码农,一直学习才是我们的常态,所以最近学习了SSH(Spring,Struts2,Hibernate)整合,数据库用的MySQL. 写了一个简单的例子,用的工具是IntelliJ Id ...

  2. spring整合struts2,hibernate

    1.导包 struts2包(不需要导入,之前学习struts2时已经导入) hibernate包(不需要导入,之前学习hibernate时已经导入) Spring包 整合hibernate的没有hib ...

  3. 一 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有一 ...

  4. spring整合mybatis(hibernate)配置

    一.Spring整合配置Mybatis spring整合mybatis可以不需要mybatis-config.xml配置文件,直接通过spring配置文件一步到位.一般需要具备如下几个基本配置. 1. ...

  5. Struts2的使用以及Spring整合Struts2

    一.如何单独使用Struts2 (1)引入struts2的jar包 commons-fileupload-1.2.1.jar freemarker-2.3.15.jar ognl-2.7.3.jar ...

  6. Spring声明式事务管理(基于注解方式实现)

    ----------------------siwuxie095                                 Spring 声明式事务管理(基于注解方式实现)         以转 ...

  7. Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)

    1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...

  8. Spring整合Struts2框架的第一种方式(Action由Struts2框架来创建)。在我的上一篇博文中介绍的通过web工厂的方式获取servcie的方法因为太麻烦,所以开发的时候不会使用。

    1. spring整合struts的基本操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2 ...

  9. Spring框架学习(5)spring整合struts2

    内容源自:spring整合struts2 一.spring框架对struts等表现层框架的整合原理 : 使用spring的ioc容器管理struts中用于处理请求的Action 将Action配置成i ...

随机推荐

  1. Opencv3.0-python: 编译报错color.cpp:7456: error: (-215) scn == 3 || scn == 4 的解决方案

    结合Opencv3.0读取视频时,出现报错:C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:11111: error: ( ...

  2. STM32串口一直进中断

    调试过程中遇到了使用串口什么都没接却一直进中断,接串口线到电脑上测试又正常的问题. 网上有人说需要将USART的RX模式从输入浮空改成输入上拉,改后测试正常,问题解决. 分析可能是什么都不接时浮空模式 ...

  3. 浅谈style.height、clientHeight、offsetHeight、scrollHeight

    先分别介绍以下,以下资料来自MDN HTMLElement.offsetHeight 是一个只读属性,它返回该元素的像素高度,高度包含该元素的垂直内边距和边框,且是一个整数. Element.clie ...

  4. 20155338 《JAVA程序设计》实验五网络编程与安全实验报告

    20155338 <JAVA程序设计>实验五网络编程安全实验报告 实验内容 实验一: •两人一组结对编程: •结对实现中缀表达式转后缀表达式的功能 MyBC.java •结对实现从上面功能 ...

  5. SQL基本数据类型等

    bit   类似C#中的bool类型   true/false int   整型 nvarchar  字符串类型 float   小数型 decimal(,) 小数型  (限制小数位数) dateti ...

  6. charles基本使用文档

    Charles 主要的功能包括: 截取 Http 和 Https 网络封包. 支持重发网络请求,方便后端调试. 支持修改网络请求参数. 支持网络请求的截获并动态修改. 支持模拟慢速网络. Charle ...

  7. Zabbix远程执行命令

    原文发表于cu:2016-06-14 Zabbix触发器(trigger)达到阀值后会有动作(action)执行:发送告警信息或执行远程命令. 本文主要配置验证zabbix执行远程命令. 一.环境 S ...

  8. java之接口开发-初级篇-webservice协议

    webservice协议 客户端: 客户端生成使用soapUI生成 外部提供webservice地址,地址后加?wsdl.选择好目录然后生成,放到项目中实现 服务端: web.xml平级目录下创建se ...

  9. Github三次学习

    作者声明:本文参照aicoder.com马伦老师的文档,根据自己的学习情况而做的笔记,仅供交流学习. Git入门到高级教程 为什么要进行项目文件的版本管理 代码备份和恢复 团队开发和协作流程 项目分支 ...

  10. css 元素水平垂直方向居中

    html部分 <div class="parent"> <div class="child"> - -居中- - </div> ...