applicationContext.xml文件配置模板
<?xml version="1.0" encoding="gb2312"?>
<!-- Spring配置文件的DTD定义-->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!-- Spring配置文件的根元素是beans-->
<beans>
<!--定义数据源,该bean的ID为dataSource-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- 指定数据库驱动-->
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<!-- 指定连接数据库的URL-->
<property name="url"><value>jdbc:mysql://wonder:3306/j2ee</value></property>
<!-- root为数据库的用户名-->
<property name="username"><value>root</value></property>
<!-- pass为数据库密码-->
<property name="password"><value>pass</value></property>
</bean>
<!--定义Hibernate的SessionFactory-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 依赖注入数据源,注入正是上文定义的dataSource-->
<property name="dataSource"><ref local="dataSource"/></property>
<!-- mappingResouces属性用来列出全部映射文件>
<property name="mappingResources">
<list>
<!--以下用来列出所有的PO映射文件-->
<value>lee/Person.hbm.xml</value>
</list>
</property>
<!--定义Hibernate的SessionFactory的属性 -->
<property name="hibernateProperties">
<props>
<!-- 指定Hibernate的连接方言-->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- 不同数据库连接,启动时选择create,update,create-drop-->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!-- 配置Person持久化类的DAO bean-->
<bean id="personDao" class="lee.PersonDaoImpl">
<!-- 采用依赖注入来传入SessionFactory的引用-->
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
</beans>
applicationContext.xml文件配置模板的更多相关文章
- web.xml文件配置模板
直接贴完整代码,当然,spring的核心控制器依赖包需要通过mean提前配置 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.// ...
- spring +springmvc+mybatis组合applicationContext.xml文件配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- SSH框架整合--applicationContext.xml文件配置实例
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- dispatcher-servlet.xml文件配置模板
完整代码如下: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http:/ ...
- SSH applicationContext.xml文件配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- ssh2学习-applicationContext.xml文件配置-----<context:annotation-config/>详解
当我们需要使用BeanPostProcessor时,直接在Spring配置文件中定义这些Bean显得比较笨拙,例如: 使用@Autowired注解,必须事先在Spring容器中声明AutowiredA ...
- Spring框架入门之基于xml文件配置bean详解
关于Spring中基于xml文件配置bean的详细总结(spring 4.1.0) 一.Spring中的依赖注入方式介绍 依赖注入有三种方式 属性注入 构造方法注入 工厂方法注入(很少使用,不推荐,本 ...
- Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)
<bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...
- SSH整合,applicationContext.xml中配置hibernate映射文件问题
今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...
随机推荐
- CentOS 6.4 系统下的MySQL的主从库配置
首先了解到一. 二一.(MySQL下创建用户并且赋予权限)root用户创建yong用户的SQL语句 CREATE USER 'yong'@'localhost' IDENTIFIED BY 'yong ...
- POJ 3416 Crossing
树状数组+离线操作 #include<stdio.h> #include<string.h> #include<math.h> #include<algori ...
- VBS基础篇 - 循环语句(3) - For...Next
VBS基础篇 - 循环语句(3) - For...Next 指定循环次数,使用计数器重复运行语句,语法结构如下: 1 2 3 4 5 For counter = start To end [Ste ...
- C# var 隐式类型 var 用法 特点
var 关键字是C# 3.0 开始,在方法范围中声明的变量: var有以下特点: * 1.var在编译器编译的时候根据初始值推断出其的类型 * 2.不能赋值除了初始值类型之外的其他类 ...
- ASP.NET—013:实现带控件的弹出层(弹出框)
http://blog.csdn.net/yysyangyangyangshan/article/details/38458169 在页面中用到弹出新页面的情况比较多的,一般来说都是使用JS方法sho ...
- DOM操作-引用同级的元素
代码: ———————————————————————————————— <script type="text/javascript"> //获取 ...
- Django:之CMDB资源系统
渐谈CMDB需要内容,ITIL.CMDB介绍.Django自定义用户认证.Restful规范.资产管理功能开发. ITIL介绍 TIL即IT基础架构库(Information Technology I ...
- 剑指offer青蛙跳台阶问题
(1)一只青蛙一次可以跳上 1 级台阶,也可以跳上2 级.求该青蛙跳上一个n 级的台阶总共有多少种跳法. //递归方式 public static int f(int n) { //参数合法性验证 ...
- Inno Setup入门(六)——在程序目录下创建文件
创建文件夹可以使用[dirs]段实现,代码如下: [setup] ;全局设置,本段必须 AppName=Test AppVerName=TEST DefaultDirName="E:\TES ...
- python 邮件报警
为了以后方便使用邮件报警 我这边直接写入一推报警模板 方便以后使用 加入模块 import smtplib from email.mime.text import MIMEText from emai ...