spring文件的配置 方便以后查看


 1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:aop="http://www.springframework.org/schema/aop"
5 xmlns:tx="http://www.springframework.org/schema/tx"
6 xmlns:context="http://www.springframework.org/schema/context"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
9 http://www.springframework.org/schema/aop
10 http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
11 http://www.springframework.org/schema/context
12 http://www.springframework.org/schema/context/spring-context-2.5.xsd
13 http://www.springframework.org/schema/tx
14 http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
15 <!-- 主键扫描 -->
16 <context:component-scan base-package="kite.dao.impl,kite.service.impl,kite.struts2.action"></context:component-scan>
17
18 <!--
19 分散配置
20 -->
21 <context:property-placeholder location="classpath:jdbc.properties" />
22 <!--
23 数据源 c3p0
24
25 -->
26 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
27 <property name="jdbcUrl" value="${jdbc.url}"></property>
28 <property name="user" value="${jdbc.username}"></property>
29 <property name="password" value="${jdbc.password}"></property>
30 <property name="driverClass" value="${jdbc.driverClass}"></property>
31
32 <property name="maxPoolSize" value="${c3p0.pool.size.maxsize}"></property>
33 <property name="minPoolSize" value="${c3p0.pool.size.minsize}"></property>
34 <property name="initialPoolSize" value="${c3p0.pool.size.init}"></property>
35 <property name="acquireIncrement" value="${c3p0.pool.size.increment}"></property>
36 </bean>
37
38 <!--
39 本地会话工厂bean,spring整合hibernate的核心入口
40 -->
41 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
42 <!-- 注入数据源 -->
43 <property name="dataSource" ref="dataSource"></property>
44 <!-- 指定hibernate配置文件的位置 -->
45 <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
46 <!-- 指定映射文件的位置 -->
47 <property name="mappingDirectoryLocations">
48 <list>
49 <value>classpath:kite/domain</value>
50 </list>
51 </property>
52 </bean>
53 <!-- 事务管理器,在service层面上实现事务管理,而且达到平台无关性 -->
54 <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
55 <property name="sessionFactory" ref="sessionFactory" />
56 </bean>
57
58 <!-- 配置事务通知 -->
59 <tx:advice id="txAdvice" transaction-manager="txManager">
60 <tx:attributes>
61 <tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT" />
62 <tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT" />
63 <tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT" />
64 <tx:method name="batch*" propagation="REQUIRED" isolation="DEFAULT" />
65 <tx:method name="new*" propagation="REQUIRED" isolation="DEFAULT" />
66
67 <tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
68 <tx:method name="load*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
69 <tx:method name="find*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
70
71 <tx:method name="*" propagation="REQUIRED" isolation="DEFAULT" />
72 </tx:attributes>
73 </tx:advice>
74
75 <!-- aop事务配置 -->
76 <aop:config>
77 <aop:advisor advice-ref="txAdvice" pointcut="execution(* *..*Service.*(..))"/>
78 </aop:config>
79 </beans>

spring文件的配置 方便以后查看

时间: 2024-08-26 21:47:54

spring文件的配置 方便以后查看的相关文章

spring中缓存配置

缓存spring文件的配置: <?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:aop="http://www.springframew

spring在xml文件中配置bean的三种方法

一.最常见,也是缺省,是调用spring的缺省工厂类 spring缺省工厂类:org.springframework.beans.factory.support.DefaultListableBeanFactory使用其静态方法preInstantiateSingletons() 配置文件中最普通最基本的定义一个普通bean<bean id="DvdTypeDAOBean" class="com.machome.dvd.impl.DvdTypeDAO" >

Spring AOP--基于XML文件的配置

Spring AOP的配置可以基于注解,也可以基于XML文件.前面几篇都是使用注解的方式.下面介绍下使用XML文件如何配置 使用的测试类和切面类都类似.只需要属于AOP的注解去掉即可.下面是AOP的XML配置: 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:

spring boot application.properties文件外部配置

spring boot application.properties文件外部配置 官方文档 原文地址:https://www.cnblogs.com/lwmp/p/9836791.html

Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)

<bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil" lazy-init="false"> <property name="locations"> <list> <value>classpath:config/sys.properties</value> &

配置spring文件时候出现的小问题

Spring中的配置bean有两种方式,今天做毕业设计的时候想使用注解的方式(简单,方便)自动扫描装配bean 大概是这样的语句 <!-- 自动扫描与装配bean --> <context:component-scan base-package="cn.hlg.oa"></context:component-scan> 但是发现会出现一个错误 The prefix "context" for element "conte

spring security3.2配置---权限管理

之前已经在我的博客中发过security的运行流程图了,大家可以先去看看那个图再看这篇.今天我主要在这里贴出了security配置中的几个重要的类和两个xml配置文件,基本上控制权限的就是这几个文件了.因为最近都比较忙,一直没有时间发出来,导致有点忘记配置时的过程了,所以忘记了一些细节的内容,原本我打算写的详细一点的,但现在都有点忘记了,我在这里就不再一一写出来了,因为在每个文件的方法或配置里,我用注释说明了一些配置时所遇到的问题,大家可以看看,可能比较难看,因为表达可能不是很好,有些写得比较详

spring aop + xmemcached 配置service层缓存策略

Memcached 作用与使用 基本介绍 1,对于缓存的存取方式,简言之,就是以键值对的形式将数据保存在内存中.在日常业务中涉及的操作无非就是增删改查.加入缓存机制后,查询的时候,对数据进行缓存,增删改的时候,清除缓存即可.这其中对于缓存的闭合就非常重要,如果缓存没有及时得到更新,那用户就会获取到过期数据,就会产生问题. 2,对于单一业务的缓存管理(数据库中只操作单表),只需生成一个key,查询时,使用key,置入缓存:增删改时,使用key,清除缓存.将key与表绑定,操作相对简单. 3,但是在

Spring的bean配置

IOC其实是从我们平常new一个对象的对立面来说的,我们平常使用的对象一般直接使用关键字类new一个对象,患处很显然,使用new那么就表示当前模块已经不知不觉和new出的对象耦合了,而我们通常都是更高层次的抽象模块调用底层实现模块,这样就产生模块依赖于具体的实现,这与我们JAVA中提倡的面向接口面向抽象编程是相冲突的,而且这样做也带来系统的模块架构问题.很简单的例子,在进行数据库操作的时候,总是业务层调用DAO层,DAO一般采用接口开发,这在一定程度上满足了松耦合,使业务逻辑层不依赖于具体的DA