<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<context:component-scan
base-package="com.bit.springboard"></context:component-scan>
<!-- <aop:aspectj-autoproxy> </aop:aspectj-autoproxy> -->
<!-- 외부파일참조 -->
<context:property-placeholder
location="classpath:config/db.properties" />
<!-- db 접속 객체인 Datasource bean 등록 -->
<bean id="dataSource"
class="org.apache.commons.dbcp2.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<!-- 이게 어디있는 jdb에서 가져와서 이렇게 쓰는거임? -->
<!-- -->
</bean>
<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--트랜잭션 설정(DDL 종료 후 자동으로 COmmit이나 rollback호출) -->
<!-- 트랜젝션을 관리해주는 트랜잭션 매니저라는것 빈 객체로 만들어서 사용해야한다. TransactionManager -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource">
</property>
</bean>
<tx:advice id= "txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*"></tx:method>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="txPointcut" expression="execution(* com.bit.springboard.service..*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"></aop:advisor>
</aop:config>
<!-- get으로시작하는 메소드 제외하고 조인하는 메소드들에서 TXADvice에 의해서트랜젝션이 자동으로 실행되도록 설정을 해준거.
-->
</beans>
댓글 영역