1234567891011121314151617181920212223242526272829303132333435 |
- <?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/tx http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <context:component-scan base-package="com.lovecoding" />
- <context:property-placeholder location="mysql.properties" />
- <!-- 配置数据库事务对象 -->
- <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
- <property name="dataSource" ref="dataSource" />
- </bean>
- <!-- 启动注解配置数据库事务 -->
- <tx:annotation-driven transaction-manager="dataSourceTransactionManager" />
- <!-- 数据源 -->
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <property name="username" value="${mysql.username}" ></property>
- <property name="driverClassName" value="${mysql.driver}" ></property>
- <property name="password" value="${mysql.passwd}" ></property>
- <property name="url" value="${mysql.url}" ></property>
- </bean>
- <!-- 配置 Spring jdbc 对象 -->
- <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
- <property name="dataSource" ref="dataSource" />
- </bean>
- </beans>
|