From 50aa64b8f06b0ea9cb03842e40f6ab4564dddcb8 Mon Sep 17 00:00:00 2001 From: SeoJin Kim Date: Sat, 8 Aug 2020 00:26:47 +0900 Subject: [PATCH] =?UTF-8?q?MyBatis=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80,=20SQLSessionFactory=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 라이브러리 추가 mybatis / mybatis-spring / spring-jdbc / spring-tx - 연결 테스트 -DataSourceTests.java 통한 테스트 --- VamPa/pom.xml | 26 +++++++++++++++++++ .../webapp/WEB-INF/spring/root-context.xml | 4 +++ .../java/com/vam/sample/DataSourceTests.java | 11 ++++++-- .../maven/com.vam/controller/pom.properties | 2 +- .../META-INF/maven/com.vam/controller/pom.xml | 26 +++++++++++++++++++ VamPa_MySQL/pom.xml | 26 +++++++++++++++++++ .../webapp/WEB-INF/spring/root-context.xml | 4 +++ .../com/vam/persistence/DataSourceTests.java | 11 ++++++-- .../maven/com.vam/controller/pom.properties | 2 +- .../META-INF/maven/com.vam/controller/pom.xml | 26 +++++++++++++++++++ 10 files changed, 132 insertions(+), 6 deletions(-) diff --git a/VamPa/pom.xml b/VamPa/pom.xml index 9f57708..4793dc8 100644 --- a/VamPa/pom.xml +++ b/VamPa/pom.xml @@ -131,6 +131,32 @@ HikariCP 3.4.2 + + + + + org.mybatis + mybatis + 3.5.3 + + + + org.mybatis + mybatis-spring + 2.0.3 + + + + org.springframework + spring-tx + ${org.springframework-version} + + + + org.springframework + spring-jdbc + ${org.springframework-version} + diff --git a/VamPa/src/main/webapp/WEB-INF/spring/root-context.xml b/VamPa/src/main/webapp/WEB-INF/spring/root-context.xml index 6880b3b..f222aa9 100644 --- a/VamPa/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/VamPa/src/main/webapp/WEB-INF/spring/root-context.xml @@ -15,6 +15,10 @@ + + + + diff --git a/VamPa/src/test/java/com/vam/sample/DataSourceTests.java b/VamPa/src/test/java/com/vam/sample/DataSourceTests.java index 2420987..4bb513f 100644 --- a/VamPa/src/test/java/com/vam/sample/DataSourceTests.java +++ b/VamPa/src/test/java/com/vam/sample/DataSourceTests.java @@ -4,6 +4,8 @@ import java.sql.Connection; import javax.sql.DataSource; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -17,13 +19,18 @@ public class DataSourceTests { @Autowired private DataSource dataSource; + @Autowired + private SqlSessionFactory sqlSessionFactory; + @Test public void testConnection() { try( - Connection con = dataSource.getConnection(); + Connection con = dataSource.getConnection(); + SqlSession session = sqlSessionFactory.openSession(); ){ - System.out.println("con="+con); + System.out.println("con=" + con); + System.out.println("session=" + session); }catch(Exception e) { e.printStackTrace(); diff --git a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index 25f0d93..e9210cf 100644 --- a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Sat Aug 08 00:16:06 KST 2020 +#Sat Aug 08 00:23:00 KST 2020 version=1.0.0-BUILD-SNAPSHOT groupId=com.vam m2e.projectName=VamPa diff --git a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml index 9f57708..4793dc8 100644 --- a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml +++ b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml @@ -131,6 +131,32 @@ HikariCP 3.4.2 + + + + + org.mybatis + mybatis + 3.5.3 + + + + org.mybatis + mybatis-spring + 2.0.3 + + + + org.springframework + spring-tx + ${org.springframework-version} + + + + org.springframework + spring-jdbc + ${org.springframework-version} + diff --git a/VamPa_MySQL/pom.xml b/VamPa_MySQL/pom.xml index fca2307..2bf232f 100644 --- a/VamPa_MySQL/pom.xml +++ b/VamPa_MySQL/pom.xml @@ -125,6 +125,32 @@ 3.4.2 + + + + org.mybatis + mybatis + 3.5.3 + + + + org.mybatis + mybatis-spring + 2.0.3 + + + + org.springframework + spring-tx + ${org.springframework-version} + + + + org.springframework + spring-jdbc + ${org.springframework-version} + + javax.inject diff --git a/VamPa_MySQL/src/main/webapp/WEB-INF/spring/root-context.xml b/VamPa_MySQL/src/main/webapp/WEB-INF/spring/root-context.xml index 014e586..f7146bf 100644 --- a/VamPa_MySQL/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/VamPa_MySQL/src/main/webapp/WEB-INF/spring/root-context.xml @@ -15,6 +15,10 @@ + + + + diff --git a/VamPa_MySQL/src/test/java/com/vam/persistence/DataSourceTests.java b/VamPa_MySQL/src/test/java/com/vam/persistence/DataSourceTests.java index 62eaaa5..aee83ff 100644 --- a/VamPa_MySQL/src/test/java/com/vam/persistence/DataSourceTests.java +++ b/VamPa_MySQL/src/test/java/com/vam/persistence/DataSourceTests.java @@ -4,6 +4,8 @@ import java.sql.Connection; import javax.sql.DataSource; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -17,13 +19,18 @@ public class DataSourceTests { @Autowired private DataSource dataSource; + @Autowired + private SqlSessionFactory sqlSessionFactory; + @Test public void testConnection() { try( - Connection con = dataSource.getConnection(); + Connection con = dataSource.getConnection(); + SqlSession session = sqlSessionFactory.openSession(); ){ - System.out.println("con="+con); + System.out.println("con=" + con); + System.out.println("session=" + session); }catch(Exception e) { e.printStackTrace(); diff --git a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index ff3492c..892e9f2 100644 --- a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Sat Aug 08 00:16:25 KST 2020 +#Sat Aug 08 00:23:18 KST 2020 version=1.0.0-BUILD-SNAPSHOT groupId=com.vam m2e.projectName=VamPa_MySQL diff --git a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml index fca2307..2bf232f 100644 --- a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml +++ b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.xml @@ -125,6 +125,32 @@ 3.4.2 + + + + org.mybatis + mybatis + 3.5.3 + + + + org.mybatis + mybatis-spring + 2.0.3 + + + + org.springframework + spring-tx + ${org.springframework-version} + + + + org.springframework + spring-jdbc + ${org.springframework-version} + + javax.inject