-
스프링 트랜잭션 처리JAVA 2019. 1. 24. 13:15
환경 설정
1.context-mapper.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"
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.xsd">
<!-- 이부분 추가-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
</beans>
2.서블릿 설정 화일-action-context.xml
xmlns:tx="http://www.springframework.org/schema/tx"
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
<!--@ @Transactional을 사용하기 위한 설정 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
3.Service Class
<!-- 트랜잭션을 적용할 함수에 어노테이션 추가-->
@Transactional
@Override
public void deleteContent(Map<String, Object> map) throws Exception {
log.debug("commandMap==================================>"+map.toString());
mcAdminDao.deleteFileList(map);
mcAdminDao.delete("McContents.deleteContents", map);
//컨텐츠 삭제 될때 함께 삭제
mcAdminDao.delete("push_sql.PushDeleteByArticleID", map);
}
'JAVA' 카테고리의 다른 글
이클립스에서 톰캣서버로 원격배포하기 (0) 2018.07.20 getServletOutputStream() 과 getWriter()는 동시 사용 불가능 (0) 2018.07.16 스프링mvc에서 Ajax and Json View (0) 2017.05.30 JAVA_서블릿 파일 업로드 샘플1 (0) 2017.05.28 vector, ArrayList, LinkedList 차이 (0) 2017.05.14