配置文件如下:<applicationContext.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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-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/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<context:component-scan base-package="com.xskj.model, com.xskj.repository, com.xskj.service">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>

<!--在原来类的上面加功能-->
<aop:aspectj-autoproxy proxy-target-class="true" />

<!-- 开启事务注解,只对当前配置有效 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

<!--jpa的仓储,你包的位置,前缀,-->
<jpa:repositories base-package="com.xskj.repository" repository-impl-postfix="Impl"
entity-manager-factory-ref="entityManagerFactory" transaction-manager-ref="transactionManager" />

<!--数据源-->
<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"> <!--oracle的驱动-->
<value>oracle.jdbc.driver.MYSQL</value>
<!--
<value>oracle.jdbc.driver.OracleDriver</value>
-->
</property>
<property name="url"><!--客户端地址-->
<!--<value>jdbc:oracle:thin:@localhost:1521:orcl</value>-->
<value>jdbc:oracle:thin:@192.168.8.14:3306:springBoot_data</value>
</property>
<property name="username"> <!--用户名-->
<!-- <value>scott</value>-->
<value>root</value>
</property>
<property name="password"> <!--密码-->
<!--<value>tiger</value>-->
<value>123</value>
</property>
</bean>

<!--事物管理-->
<bean />
</bean>
</beans>

相关文章: