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. 新版mysql修改root密码

  2. hdu 1863 畅通project kruskal || prim

    简单最小生成树,畅通project.这三道题目都是练习最小生成树的. 注意一下推断是否有通路时,kruskal能够推断每一个点的祖先是否同样.prim能够推断每一个点是否都加进集合里面了,也就是说是否 ...

  3. 控制面板项 .cpl 文件说明

    控制面板项 .cpl 文件说明 appwiz.cpl               程序和功能.卸载或更改程序 bthprops.cpl             蓝牙控制面板 desk.cpl      ...

  4. 73.fseek与宽字符读取文件

    fseek //文件路径 ] = "1.txt"; //FILE *pf = fopen(path, "a+");//尾部添加,文件指针在尾部 //FILE * ...

  5. jQuery返回值:jQuery对象

    $(function(){ //返回值 alert($); //jQuery //以下返回的全是jQuery对象 alert($()); alert($('#box')); alert($('#box ...

  6. 为RecyclerView添加item的点击事件

    RecyclerView侧重的是布局的灵活性,虽说可以替代ListView但是连基本的点击事件都没有,这篇文章就来详细讲解如何为RecyclerView的item添加点击事件,顺便复习一下观察者模式. ...

  7. JAVA 多线程和进程概念的引入

    1.并发和并行 并行:指两个或多个时间在同一时刻发生(同时发生): 并发:指两个或多个事件在一个时间段内发生. 在操作系统中,安装了多个程序,并发指的是在一段时间内宏观上有多个程序同时运行,这在单 C ...

  8. Node里面的对象创建问题

    1.利用new Object()创建时 var a =new Object() a.b = 1 console.log(a) // 打印出来是[object Object] console.log(J ...

  9. 用实力让情怀落地!阅兵前线指挥车同款电视TCL&#160;H8800受捧

        近期.一则重磅消息刷爆了平面媒体.微博.朋友圈等各个传播渠道:TCL曲面电视H8800正式入驻大阅兵前线指挥车以及国旗护卫队荣誉室.宣告代表眼下中国彩电业最高技术水准的曲面电视,正式走上大阅兵 ...

  10. java 并发原子性与易变性 来自thinking in java4 21.3.3

    java 并发原子性与易变性  具体介绍请參阅thinking in java4 21.3.3 thinking in java 4免费下载:http://download.csdn.net/deta ...