[Spring][쇼핑몰 프로젝트][27] 업로드 이미지 정보 등록 - 5 (트랜잭션 적용)

https://kimvampa.tistory.com/231
This commit is contained in:
SeoJin Kim
2021-06-14 17:06:11 +09:00
parent 6e101cb9fd
commit bb8db75b6a
5 changed files with 24 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.vam.mapper.AdminMapper;
import com.vam.model.AttachImageVO;
@@ -21,6 +22,7 @@ public class AdminServiceImpl implements AdminService {
private AdminMapper adminMapper;
/* 상품 등록 */
@Transactional
@Override
public void bookEnroll(BookVO book) {

View File

@@ -3,9 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
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/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<!-- <property name="driverClassName" value="oracle.jdbc.pool.OracleDataSource"></property>
@@ -43,6 +45,12 @@
</property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="datasource"></property>
</bean>
<tx:annotation-driven />
<context:component-scan base-package="com.vam.sample"></context:component-scan>

View File

@@ -45,11 +45,11 @@ public class AdminServiceTests {
image1.setFileName("test Image 1");
image1.setUploadPath("test image 1");
image1.setUuid("test1111");
image1.setUuid("test11112");
image2.setFileName("test Image 2");
image2.setUploadPath("test image 2");
image2.setUuid("test2222");
image2.setUuid("test22222");
imageList.add(image1);
imageList.add(image2);

View File

@@ -4,6 +4,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.vam.mapper.AdminMapper;
import com.vam.model.BookVO;
@@ -20,6 +21,7 @@ public class AdminServiceImpl implements AdminService {
private AdminMapper adminMapper;
/* 상품 등록 */
@Transactional
@Override
public void bookEnroll(BookVO book) {

View File

@@ -3,9 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
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/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<!-- <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
@@ -43,6 +45,12 @@
</property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="datasource"></property>
</bean>
<tx:annotation-driven />
<context:component-scan base-package="com.vam.sample"></context:component-scan>
<mybatis-spring:scan base-package="com.vam.mapper"/>