spring的xml代码如下:
<?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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd ">
<!-- <import resource="" /> -->
<context:property-placeholder location="classpath:source/jdbc.properties" />
<!-- 通过JNDI配置DataSource <bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"> <value>java:comp/env/jdbc/jboa</value> </property>
</bean> -->
<!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="username" value="${jdbc.username}" /> <property name="password"
value="${jdbc.password}"/> <property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/> </bean> -->
<!-- C3P0 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<!--连接池最大连接数 -->
<property name="maxPoolSize" value="40"></property>
<!--连接池最小连接数 -->
<property name="minPoolSize" value="1"></property>
<!--初始化参数 -->
<property name="initialPoolSize" value="1"></property>
<!--连接的最大空闲时间,超时的连接将被丢弃,单位:秒 -->
<property name="maxIdleTime" value="60"></property>
<!--没有连接可用时,等待连接的时间,单位毫秒 -->
<property name="checkoutTimeout" value="2000"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- <property name="configLocation" value="classpath:hibernate.cfg.xml">
</property> -->
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
<!-- hbm文件已改成通过插件加载 -->
<property name="mappingResources">
<list>
<value>com/bdqn/wls/entity/xml/Book.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/OrderOperate.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/BookType.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Department.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Menu.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Mistake.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Order.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Person.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Position.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Power.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Role.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Send.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Site.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Stock.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/StockRecord.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/StoreRoom.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Supplier.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Supply.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/Transport.hbm.xml</value>
<value>com/bdqn/wls/entity/xml/User.hbm.xml</value>
</list>
</property>
</bean>
<import resource="applicationContext-*" />
<!-- 声明式事务 -->
<!-- 事务管理器 -->
<bean class="org.springframework.orm.hibernate3.HibernateTransactionManager"
id="transactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 事务管理通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- aop -->
<aop:config>
<aop:pointcut expression="execution(* com.bdqn.wls.service.impl.*.*(..))"
id="bizMethod" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethod" />
</aop:config>
</beans>