Tidhy
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的更多相关文章
- Javascript和jquery事件-鼠标移入移出事件
javascript使用mouseover和mouseout,只在css中支持hover jquery支持mouseover和mouseout,封装了mouseenter.mouseleave事件函数 ...
随机推荐
- jquery如何阻止子元素相应mouseout事件
jquery如何阻止子元素相应mouseout事件:mouseout有一个特点,当鼠标移入子元素的时候,也会触发此事件,但是在实际应用中这个特点往往不是我们想要的,下面就通过代码实例介绍一下如何实现此 ...
- VS Code 好用的扩展程序
1. Atom One Dark Theme.看得比较舒服的主题. 2. Beautify.格式化代码必备. 3. Bracket Pair Colorizer.不同层次的括号颜色不同,光标在括号间时 ...
- Flask项目之手机端租房网站功能测试(完结)
说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 目录 一丶注册和登录以及用户退出功能 二丶上传头像功能和修改用户名功能测试 三丶发布房源以及实名认证功能测试 四丶网站房屋搜索功能 ...
- <link rel="shortcut icon" href="Xubuntu.ico" type="image/x-icon" /> <LINK href="Xubuntu.ico" rel="shortcut icon"> <link href="Xubuntu.ico" rel="B
<link rel="shortcut icon" href="Xubuntu.ico" type="image/x-icon" /& ...
- 1、DOM4J简介
1.DOM4J简介 DOM4J是 dom4j.org 出品的一个开源 XML 解析包.DOM4J应用于 Java 平台,采用了 Java 集合框架并完全支持 DOM,SAX 和 JAXP. DOM4J ...
- [React] Call setState with null to Avoid Triggering an Update in React 16
Sometimes it’s desired to decide within an updater function if an update to re-render should be trig ...
- linux下多进程的文件拷贝与进程相关的一些基础知识
之前实现了用文件IO的方式能够实现文件的拷贝,那么对于进程而言,我们是否也能够实现呢? 答案是肯定的. 进程资源: 首先我们先回想一下,进程的执行须要哪些资源呢?其资源包含CPU资源,内存资源,当然还 ...
- Dell shareplex 与HVR数据复制软件
今天大体了解了一下Dell shareplex 数据复制软件,网址为:http://software.dell.com/products/shareplex/ 从该网址能够看到. shareplex作 ...
- GitHub上常用命令(工作中几乎每天用到的命令)
查看自己当前分支 git branch 查看远程和本地分支 git branch -a 查看origin下的分支 git config -vv git config --lis 创建分支 git br ...
- "C:\Program Files\Internet Explorer\iexplore.exe" -extoff 无加载项启动IE 浏览器打开时全屏模式
"C:\Program Files\Internet Explorer\iexplore.exe" -extoff 无加载项启动IE浏览器打开时全屏模式