Spring的applicationContext.xml文件
| 以下是详解Spring的applicationContext.xml文件代码: <!-- 头文件,主要注意一下编码 --> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- 建立数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <!-- 数据库驱动,我这里使用的是Mysql数据库 --> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <!-- 数据库地址,这里也要注意一下编码,不然乱码可是很郁闷的哦! --> <property name="url"> <value> jdbc:mysql://localhost:3306/tie?useUnicode=true&characterEncoding=utf-8 </value> </property> <!-- 数据库的用户名 --> <property name="username"> <value>root</value> </property> <!-- 数据库的密码 --> <property name="password"> <value>123</value> </property> </bean> <!-- 把数据源注入给Session工厂 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <!-- 配置映射文件 --> <property name="mappingResources"> <list> <value>com/alonely/vo/User.hbm.xml</value> </list> </property> </bean> <!-- 把Session工厂注入给hibernateTemplate --> <!-- 解释一下hibernateTemplate:hibernateTemplate提供了很多方便的方法,在执行时自动建立 HibernateCallback 对象,例如:load()、get()、save、delete()等方法。 --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <constructor-arg> <ref local="sessionFactory" /> </constructor-arg> </bean> <!-- 把DAO注入给Session工厂 --> <bean id="userDAO" class="com.alonely.dao.UserDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <!-- 把Service注入给DAO --> <bean id="userService" class="com.alonely.service.UserService"> <property name="userDAO"> <ref local="userDAO" /> </property> </bean> <!-- 把Action注入给Service --> <bean name="/user" class="com.alonely.struts.action.UserAction"> <property name="userService"> <ref bean="userService" /> </property> </bean> </beans> |
Spring的applicationContext.xml文件的更多相关文章
- ApplicationContext.xml文件详解
想必用过Spring的程序员们都有这样的感觉,Spring把逻辑层封装的太完美了(个人感觉View层封装的不是很好).以至于有的初学者都不知道Spring配置文件的意思,就拿来用了.所以今天我给大家详 ...
- Spring配置文件详解 - applicationContext.xml文件路径
spring的配置文件applicationContext.xml的默认地址在WEB-INF下,只要在web.xml中加入代码 org.springframework.web.context.Cont ...
- Spring配置文件详解 – applicationContext.xml文件路径
Spring配置文件详解 – applicationContext.xml文件路径 Java编程 spring的配置文件applicationContext.xml的默 ...
- Spring中加载ApplicationContext.xml文件的方式
Spring中加载ApplicationContext.xml文件的方式 原文:http://blog.csdn.net/snowjlz/article/details/8158560 1.利用Cla ...
- 当你的Spring IOC 容器(即applicationContext.xml文件)忘记配到web.xml 文件中时
当你的Spring IOC 容器忘记配到web.xml 文件中时,启动服务器就会报错. 部分错误如下: Caused by: org.springframework.beans.factory.NoS ...
- Spring框架找不到 applicationContext.xml文件,可能是由于applicationContext.xml文件的路径没有放在根目录下造成的
Spring框架找不到 applicationContext.xml文件,可能是由于applicationContext.xml文件的路径没有放在根目录下造成的
- Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)
<bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...
- spring将service添加事务管理,在applicationContext.xml文件中的设置
在applicationContext.xml文件中的设置为: <beans> <bean id="sessionFactory" class="org ...
- web.xml中配置Spring中applicationContext.xml的方式
2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicatio ...
随机推荐
- Android开发之手势滑动(滑动手势监听)详解
Android开发之手势滑动(滑动手势监听)详解 在Android应用中,经常需要手势滑动操作,比如上下滑动,或左右方向滑动,处理手势滑动通常有两种方法:一种是单独实现setOnTouchListen ...
- C#随机函数random()典型用法集锦
C#随机函数random()典型用法集锦 Random.Next() 返回非负随机数: Random.Next(Int) 返回一个小于所指定最大值的非负随机数 Random.Next(Int,Int) ...
- Customize the SharePoint 2013 search experience with a Content Enrichment web service
Did you ever wish you had more control over how your content is indexed and presented as search resu ...
- CI框架篇之模型篇--直接操作(2)
在CI里面对数据库的操作有两种形式,一种是直接通过最原始的sql语句操作 一种则是通过CI里面的AR模型进行操作.两种操作各有千秋,应当有机的结合 现在讲解第一种操作的方式: 装载数据路操作类后就能够 ...
- ORACLE里的自增字段设置
大家都知道吧,这很坑,尤其是用惯了mysql里的自增字段设置,结果oracle里面没有的.oh,no 我用的是12c版本的,它有一个新特性,可以这样设置自增序列,在创建表是,把id设置为自增序列 cr ...
- 0-C相关01:NSlog函数介绍。
NSlog()函数介绍: 首先:NSlog()函数是cocoa的框架中提供的一个方法: 下图中最上方是它在Xcode中的路径: : 同样都是输出函数.下边我们来看一下,在O-C中NSlog()和在 ...
- [转]jQuery源码分析系列
文章转自:jQuery源码分析系列-Aaron 版本截止到2013.8.24 jQuery官方发布最新的的2.0.3为准 附上每一章的源码注释分析 :https://github.com/JsAaro ...
- Sdut 2151 Phone Numbers (山东省ACM第一届省赛题 A)
题目描述 We know thatif a phone number A is another phone number B's prefix, B is not able to becalled. ...
- js判断用户进入设备代码
var system ={ win : false, mac : false, xll : false }; //检测平台 var p = navigator.platform; system.win ...
- javascript 一串DIV跟随鼠标移动
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...