JavaBean.hbm.xml(hibernate配置方面的):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!-- name:JavaBean类全路径
table:表名字 -->
<class name="com.itheima.elec.domain.ElecText" table="elec_text">
<!-- name:主键
type:主键类型,可忽略
column:貌似也是主键 -->
<id name="textID" type="String" column="textID">
<!-- 这个uuid,名词是什么忘记 -->
<generator class="uuid"></generator>
</id>
<!-- 配置表其他的属性 -->
<property name="textName" type="String" column="textName"></property>
<property name="textDate" type="date" column="textDate"></property>
<property name="textRemark" type="String" column="textRemark"></property>
</class>
</hibernate-mapping>

hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 必须也要配置的参数有5个,4大参数,数据库的方言 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/struts_day01</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123</property>
<!-- 数据库的方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 其他配置 --> <!-- 添加JavaBean映射的文件 -->
<mapping resource="/itcast1128elec/src/com/itheima/elec/domain/ElecText.hbm.xml"/>
</session-factory>
</hibernate-configuration>

web.xml:

    <!-- 配置Spring框架整合WEB的监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <!-- 解决延迟加载的问题 -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 配置Struts2框架的核心的过滤器 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

 bean.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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 配置c3p0连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql:///ssh_crm"></property>
<property name="user" value="root"></property>
<property name="password" value="123"></property>
</bean> <!-- sessionfactory创建 -->
<!-- 配置Spring提供的支持注解ORM映射的Hibernate会话工厂 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocations" value="classpath:hibernate.cfg.xml"></property>
</bean>
<!-- 事务管理器 -->
<!-- 配置spring基于注解的声明式事务管理 -->
<bean id="transactionManager" class="org.springframework.org.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 通过setter注入Hibernate会话工厂 -->
<tx:annotation-driven transaction-manager="transactionManager" /> <!-- 三大框架注入的关系
其中name属性是类里面生成的静态方法
ref是权限类名,也可以是id
这里有些乱的
-->
<bean id="userAction" class="cn.itcast.action.UserAction" scope="prototype">
<property name="userService" ref="userService"></property>
</bean>
<bean id="userService" class="cn.itcast.service.UserService">
<property name="userDao" ref="userDaoImpl"></property>
</bean>
<bean id="userDaoImpl" class="cn.itcast.dao.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- 这个是dao类里面注入模板对象的配置,class是模板hibernate5的接口地址
和上面的基本上都是一样的
不过因为dao层继承了 HibernateDaoSupport ,所以这里可以省略了
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
-->
</beans>

Tidhy的更多相关文章

  1. Javascript和jquery事件-鼠标移入移出事件

    javascript使用mouseover和mouseout,只在css中支持hover jquery支持mouseover和mouseout,封装了mouseenter.mouseleave事件函数 ...

随机推荐

  1. 004 python 流程控制语句

    流程控制语句 1.if判断 语法 a = 10,b = 20# 1if a == 10:  print('a等于10')# 2if a > b:  print('a大于b')else:  pri ...

  2. php汉字转化为拼音函数

    <?php function Pinyin($_String, $_Code='gb2312'){ $_DataKey = "a|ai|an|ang|ao|ba|bai|ban|ban ...

  3. Oracle学习总结(8)—— 面向程序员的数据库访问性能优化法则

    特别说明: 1.  本文只是面对数据库应用开发的程序员,不适合专业DBA,DBA在数据库性能优化方面需要了解更多的知识: 2.  本文许多示例及概念是基于Oracle数据库描述,对于其它关系型数据库也 ...

  4. 常用处理字符串的SQL函数

    汇总函数:Count.Sum.AVG.MAX.min; 数学函数: ABS:绝对值.floor:给出比给定值小的最大整数. round(m,n):m为给定的值,n为小数点后保留的位数. power(m ...

  5. 【Codeforces Round #455 (Div. 2) B】Segments

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 处理出所有的线 其实就是区间. 总共有n*(n+1)/2个 然后按照左端点.右端点排序 每次取最左边的线. 多种可能就取右端点尽量小 ...

  6. 阶段复习-.NET下托管资源与非托管资源的小记

    托管资源由由程序员负责分配,在系统的二级缓存中,GC自动回收释放:而非托管资源也是由程序员负责分配,资源的释放回收也是由程序员负责,使用Dispose或者析构函数对资源进行回收,常见的非托管资源是包装 ...

  7. [转载]Google Java Style 中文版

    转自:http://www.blogjava.net/zh-weir/archive/2014/02/08/409608.html Google Java Style 中文版     基于官方文档20 ...

  8. BPX-tree

    写的匆忙 估计有BUG 修改后  会去掉这个 说明 /** * @author shuly * @date 2017/6/5. */ // hint 一日为叶,终身为叶, 最后还是要转换成 <链 ...

  9. 2.Web开发过程流程图

    转自:https://blog.csdn.net/hello_simon/article/details/19993343 最近公司在进行一系列新模块的开发,在痛苦开发的过程中,大家不时在一起进行总结 ...

  10. 1.一个WEB应用的开发流程

    先说项目开发过程中团队人员的分工协作. 一.人员安排 毕业至今的大部分项目都是独立完成,虽然也有和其他同事协作的时候,但自认为对团队协作的了解和认知都还有所欠缺.很清楚团队协作的重要性,但尚未有很好的 ...