<!-- 头文件,主要注意一下编码 -->
<?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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" >

    <!-- 建立数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- 数据库驱动,我这里使用的是Mysql数据库 -->
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url">
<value>
<!-- 数据库名称,注意编码 -->
jdbc:mysql://localhost:3306/test0920?useUnicode=true&amp;characterEncoding=utf8
</value>
</property>
<!-- 数据库登录用户名&密码 -->
<property name="username" value="root"></property>
<property name="password" value=""></property> </bean> <!-- 把数据源注入给Session工厂 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property> <!-- 把Session工厂注入给hibernateTemplate -->
<!-- hibernateTemplate提供很多方便的方法,执行时自动建立 HibernateCallback 对象,如:load()、save等。 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property> <!-- 配置映射文件 -->
<property name="mappingResources">
<list>
<!-- *.hbm.xml 在这里配置 -->
<value>com/blank/pojo/User.hbm.xml</value>
</list>
</property>
</bean> <!-- 声明式事务管理 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- 配置事务规则 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="SUPPORTS"/>
</tx:attributes>
</tx:advice>
<aop:config>
<!-- 事务要处理的类的路径 -->
<aop:pointcut id="interceptorPointCuts"
expression="execution(* com.blank.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" />
</aop:config> <!-- DAO -->
<!-- class记得要写正确 -->
<bean id="IBaseDAO" class="com.blank.dao.impl.IBaseDAO" scope="singleton">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="UserDAO" class="com.blank.dao.impl.UserDAOImpl"
parent="IBaseDAO">
</bean> <!-- Service -->
<bean id="UserServiceImpl" class="com.blank.service.impl.UserServiceImpl">
<property name="userDAO">
<ref bean="UserDAO" />
</property>
</bean> <!-- Action -->
<!-- struts使用这里的id做为class -->
<bean id="UserAction" class="com.blank.action.UserAction" scope="prototype">
<property name="userService">
<ref bean="UserServiceImpl"/>
</property>
</bean> </beans>

applicationContext.xml 基本配置的更多相关文章

  1. SSH整合,applicationContext.xml中配置hibernate映射文件问题

    今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...

  2. spring-mvc.xml 和 application-context.xml的配置与深入理解

    在java框架这个话题,前几篇文章是基于搭建ssm项目框架,以及web.xml的配置讲解,本篇主要就ssm框架的其他配置文件进行深入讲解,他们分别是:1.application-context.xml ...

  3. applicationContext.xml的配置

    想必用过Spring的程序员们都有这样的感觉,Spring把逻辑层封装的太完美了(个人感觉View层封装的不是很好).以至于有的初学者都不知道Spring配置文件的意思,就拿来用了.所以今天我给大家详 ...

  4. 在application-context.xml中配置多个property-placeholder

    如下所示,直接写多个<context:property-placeholder>标签是会报错的. <context:property-placeholder location=&qu ...

  5. SSH applicationContext.xml文件配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  6. applicationContext.xml文件配置模板

    <?xml version="1.0" encoding="gb2312"?><!--  Spring配置文件的DTD定义-->< ...

  7. spring +springmvc+mybatis组合applicationContext.xml文件配置

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  8. SSH框架整合--applicationContext.xml文件配置实例

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  9. ssh2学习-applicationContext.xml文件配置-----<context:annotation-config/>详解

    当我们需要使用BeanPostProcessor时,直接在Spring配置文件中定义这些Bean显得比较笨拙,例如: 使用@Autowired注解,必须事先在Spring容器中声明AutowiredA ...

随机推荐

  1. 【Web】Sublime Text 3 安装+注册+汉化

    Sublime Text 介绍 Sublime Text 是一个代码编辑器,也是HTML和散文先进的文本编辑器.Sublime Text是由程序员Jon Skinner于2008年1月份所开发出来,它 ...

  2. Java关键字解释及作用

    JAVA 关键字及其作用解释 1. 访问控制 1) private 私有的 private 关键字是访问控制修饰符,可以应用于类.方法或字段(在类中声明的变量). 只能在声明 private(内部)类 ...

  3. Python如何利用Xpath进行解析

    用Python做网络爬虫的时候,会对网页的信息进行提取,笔者接触的有正则表达式,BeautifulSoup,Xpath,前面两个都是在国内能够使用的,而Xpath是Chrome的一个插件,因此需要“F ...

  4. 如何将frm文件导入MySql数据库

    只要在mysql的安装文件中找到data文件夹,然后在里面建立一个文件夹,比如test.这个test其实就对应着数据库的名称,所以,你想要起什么样的数据库名称就把文件夹起什么名字. 然后把.frm文件 ...

  5. 219.01.19 bzoj3252: 攻略(长链剖分+贪心)

    传送门 长链剖分好题. 题意:给一棵带点权的树,可以从根节点到任一叶节点走kkk次,走过的点只能计算一次,问kkk次走过的点点权值和最大值. 思路: 考虑将整棵树带权长链剖分,这样链与链之间是不会重复 ...

  6. Codeforces Round #543 (Div. 2)B,C

    https://codeforces.com/contest/1121 B 题意 给你n(<=1000)个数ai,找出最多对和相等的数,每个数只能用一次,且每个数保证各不相同 题解 重点:每个数 ...

  7. Android 从相机或相册或获取图片(转)

    参考: https://github.com/ASDbobo/GetPhotoDemo Android 8.0 调取系统摄像头和相册选择图片 9.3 使用Camera拍照

  8. shell 常见面试

    1.求100以内的质数 #!/bin/bash n= ;i<=n;i++)) do ;x<=i;x++)) do b=$(( $i%$x )) ]]; then a=$a+ fi done ...

  9. Linux下启动tomcat报错RROR org.apache.catalina.core.StandardContext- Error starting static Resources java.lang.IllegalArgumentException: Document base /home/duiba/apache-tomcat/webapps/../webapps/manager do

    部署项目的时候,重启tomcat,死活起不来,很郁闷,网上巴拉了半天,结合自己的情况,找到了原因: 错误日志信息: 2018-12-13 13:52:26,992 [main] INFO org.ap ...

  10. python科学计算模块NumPy

    NumPy是Numerical Python的简称,是高性能科学计算和数据分析的基础包.其实NumPy 本身并并没有提供太多的高级的数据分析功能, 但是理解NumPy数组以及面向数组的计算将有利于你更 ...