티스토리 뷰
context 추가.
context-transaction.xml 파일이 있다면 수정. 없다면 추가.
트랜잭션 처리 할 서비스 패키지 명을 넣어준다.
or execution(* egovframework.패키지명..*Service.*(..))
context-transaction.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="egov.dataSource"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="requiredTx" expression="execution(* egovframework.com..*Impl.*(..)) or
execution(* egovframework.rte.fdl.excel.impl.*Impl.*(..))
or execution(* egovframework.패키지..*Service.*(..))
"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="requiredTx" />
</aop:config>
</beans>
AbcService.java
@Transactional 어노테이션, throws Exception
@Transactional
public int testTran(Map m) throws Exception{
int cnt = 0;
cnt = testMapper.정상쿼리(m);
cnt += testMapper.오류쿼리(m);
return cnt;
}
AbcController.java
@RequestMapping("/test/testTran.do")
public String testTran(ModelMap model, HttpServletRequest request) {
String msgCode = "O";
String msg = "";
int result = 0;
try {
testService.testTran(Map);
} catch (Exception e) {
LOGGER.error("==오류 발생==");
LOGGER.error(e.getMessage());
}
model.addAttribute("result", result);
model.addAttribute("msgCode", msgCode);
model.addAttribute("msg", msg);
return "/test/testTran";
}
'웹개발자 > java' 카테고리의 다른 글
[java] Error: opening registry key 'Software\JavaSoft\Java Runtime Environment' (0) | 2021.04.15 |
---|---|
Could not autowire. No beans of 'string' type found. (0) | 2021.01.26 |
전자정부프레임워크 hibernate-validator 적용 (spring 4.3) (0) | 2020.03.02 |
전자정부프레임워크 3.8 캐시 설정(spring 4.3) (0) | 2020.03.02 |
이미지 업로드 가로 세로 회전 현상 처리 (0) | 2020.03.01 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 블루스택
- 설치
- 다운로드
- 시즌3
- Spring
- autohotkey
- tomcat
- nginx
- mysql
- 오토핫키
- 전자정부프레임워크
- 구글 플레이 게임즈
- 달빛조각사
- 단축키
- 라즈베리파이
- eGovFramework
- java
- download
- 설정
- 배드워즈
- 베트남
- lineage2m
- mariaDB
- Spring Boot
- 수원
- 메소드 제한
- 윈도우
- 로블록스
- 호이안
- 시즌패스
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함