123456789101112131415161718192021222324252627282930313233343536 |
- <?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:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
- <!-- 外部资源导入-->
- <context:property-placeholder location="classpath:db.properties"></context:property-placeholder>
- <!-- 配置数据库-->
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <property name="username" value="${jdbc_user}"></property>
- <property name="password" value="${jdbc_password}"></property>
- <property name="url" value="${jdbc_url}"></property>
- </bean>
- <!-- 注册dao-->
- <bean id="accountDao" class="com.sf.dao.AccountDaoImpl">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <!-- 注册service-->
- <bean id="accountService" class="com.sf.service.AccountServiceImpl">
- <property name="accountDao" ref="accountDao"></property>
- </bean>
- <!-- 配置事务管理器-->
- <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <!-- 开启基于注解的事务管理-->
- <tx:annotation-driven transaction-manager="dataSourceTransactionManager"></tx:annotation-driven>
- </beans>
|