想必用过Spring的程序员们都有这样的感觉,Spring把逻辑层封装的太完美了(个人感觉View层封装的不是很好)。以至于有的初学者都不知道Spring配置文件的意思,就拿来用了。所以今天我给大家详细解释一下Spring的applicationContext.xml文件。Ok,还是通过代码加注释的方式为大家演示: 以下是详解Spring的applicationContext.xml文件代码: <!-- 头文件,主要注意一下编码 -->
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE <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>
beans
PUBLIC
"-//SPRING//DTD
BEAN//EN"
"doc.guandang.net;
} 该情况下的 Spring 配置文件:bean.xml 的内容大致如下: <beans> <description>Values Injection Sample</description> <bean id="dataSource" <!-- JndiO...
spring配置文件详解_计算机软件及应用_IT/计算机_专业资料。spring配置文件详解1.基本配置: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http:/...
spring 配置文件详解,通过 spring 的配置文件的配置你可以实现你的业务要求,下面就让我们 来看看 spring 的配置文件怎么配置: 想必用过 Spring 的程序员们都有这样...
spring配置文件详细 原创_IT/计算机_专业资料。<?xml version="1.0" encoding="UTF-8"?> <!-- 注意要引入所用到的命名空间 比如用到了事务,所以要把事务...
Spring_mvc的配置文件详解_IT/计算机_专业资料。含配置文件的解释以及MVC的快速入门步骤一,配置分发器 DispatcherServlet 是Spring MVC 的入口 所有进入Spring Web ...
spring配置文件applicationContext说明_计算机软件及应用_IT/计算机_专业资料。spring配置文件applicationContext说明今日推荐 88份文档 ...
spring配置文件各个属性详解_计算机软件及应用_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 spring配置文件各个属性详解_计算机软件及应用_IT/计算机_...
_cti*.xml classpath*:conf/spring/applicationContext_apm*.xml </context-param> contextConfigLocation 参数定义了要装入的 Spring 配置文件。 详细说明如下:...
Spring加载配置文件的三种方式_IT/计算机_专业资料。很经典的Spring加载配置文件的方式,值得一看1、 applicationContext.xml 直接放在 WEB-INF/classes 下, 把 ...
Spring配置文件总结_计算机软件及应用_IT/计算机_专业资料。Spring配置文件总结Spring 配置文件总结首先来看一个标准的 Spring 配置文件 applicationContext.xml <?xml ...
热门文档