앱)spring transaction properties mybatis Config설정 예시 샘플
<beans xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/spring-util.xsd">
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
<!-- properties -->
<util:properties id="api" location="file:${home.dir}/api${server.type}.properties" />
<!-- db transcation -->
<bean id = "dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" scope="singleton">
<property name="jndiName" value="java:/DDDS" />
<property name="resourceRef" value="true" />
</bean>
<bean id = "transcationManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="check*"/>
<tx:method name="insert*"/>
<tx:method name="update*"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:advisor id="txAdvisor" advice-ref="txAdvice" pointcut="execution(* *..service..*.*(..))" />
</aop:config>
<!-- mybatis -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" ref="classpath:config/mybatis/mybatisConfig.xml" />
<property name="mapperLocations" ref="classpath:com/**/dao/sql/*.xml" />
</bean>
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactory" />
</bean>
xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/spring-util.xsd">
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
<!-- properties -->
<util:properties id="api" location="file:${home.dir}/api${server.type}.properties" />
<!-- db transcation -->
<bean id = "dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" scope="singleton">
<property name="jndiName" value="java:/DDDS" />
<property name="resourceRef" value="true" />
</bean>
<bean id = "transcationManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="check*"/>
<tx:method name="insert*"/>
<tx:method name="update*"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:advisor id="txAdvisor" advice-ref="txAdvice" pointcut="execution(* *..service..*.*(..))" />
</aop:config>
<!-- mybatis -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" ref="classpath:config/mybatis/mybatisConfig.xml" />
<property name="mapperLocations" ref="classpath:com/**/dao/sql/*.xml" />
</bean>
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactory" />
</bean>
'백엔드개발 > 자바스프링' 카테고리의 다른 글
앱)mysql sequence 쿼리 샘플 (0) | 2018.11.14 |
---|---|
앱)mybatis config.xml (0) | 2018.11.14 |
앱)자바 enum 예제 (0) | 2018.07.09 |
앱)자바 멀티스레드 샘플 코드 (0) | 2018.07.09 |
앱)JSP(JavaServer Pages)에 대해서 (0) | 2018.07.03 |