diff --git a/.gitignore b/.gitignore index 54184f8..67ee1af 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,10 @@ log *.apk classbeanLib/* weaverLib/* -web/**/*.properties -web/**/*.xml -target -classbean +/web/**/*.properties +/web/**/*.xml +/target +/classbean .idea/ !/web/WEB-INF/prop/prop2map/*.properties # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` diff --git a/pom.xml b/pom.xml index 9a73899..382c316 100644 --- a/pom.xml +++ b/pom.xml @@ -100,6 +100,15 @@ + + + + + + + + + diff --git a/src/aiyh/utils/MybatisUtil.java b/src/aiyh/utils/MybatisUtil.java new file mode 100644 index 0000000..2859338 --- /dev/null +++ b/src/aiyh/utils/MybatisUtil.java @@ -0,0 +1,36 @@ +package aiyh.utils; + +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.session.SqlSessionManager; + +import java.io.File; +import java.io.Reader; + +/** + * @author EBU7-dev1-ayh + * create 2021/12/14 0014 15:57 + */ + + +public class MybatisUtil { + private static SqlSessionManager sqlSessionManager = null; + + private synchronized static void init(String config){ + try { + Reader resourceAsReader = Resources.getResourceAsReader("WEB-INF" + File.separator +config); + sqlSessionManager = SqlSessionManager.newInstance(resourceAsReader); + } catch (Exception e) { + e.printStackTrace(); + } + } + public static SqlSessionManager getSessionManager(String config){ + if(sqlSessionManager == null){ + synchronized (MybatisUtil.class) { + if (sqlSessionManager == null) { + init(config); + } + } + } + return sqlSessionManager; + } +} diff --git a/src/aiyh/utils/Util.java b/src/aiyh/utils/Util.java index 757fdaf..1136641 100644 --- a/src/aiyh/utils/Util.java +++ b/src/aiyh/utils/Util.java @@ -46,7 +46,7 @@ import java.util.zip.ZipEntry; /** * @author EBU7-dev1-ayh * @date 2021/8/23 0023 11:42 - * dao 工具类 + * mybatisTest.dao 工具类 */ diff --git a/src/com/api/aiyh_pcn/copy_attachment/dao/DocTemplateDao.java b/src/com/api/aiyh_pcn/copy_attachment/dao/DocTemplateDao.java index 5b18588..a742d1d 100644 --- a/src/com/api/aiyh_pcn/copy_attachment/dao/DocTemplateDao.java +++ b/src/com/api/aiyh_pcn/copy_attachment/dao/DocTemplateDao.java @@ -23,7 +23,7 @@ import java.util.Map; /** * @author EBU7-dev1-ayh * @create 2021/8/26 0026 11:14 - * copy dao + * copy mybatisTest.dao */ diff --git a/src/com/api/aiyh_pcn/fadada/web/FaDDContractController.java b/src/com/api/aiyh_pcn/fadada/web/FaDDContractController.java index 2c34efc..2c437a8 100644 --- a/src/com/api/aiyh_pcn/fadada/web/FaDDContractController.java +++ b/src/com/api/aiyh_pcn/fadada/web/FaDDContractController.java @@ -30,6 +30,7 @@ import java.util.Map; */ @Path("/v2/fadada") public class FaDDContractController { + private final FaDDContractService faDDService = new FaDDContractService(); private final FaDDContractMapping faDDContractMapping = new FaDDContractMapping(); private final ToolUtil toolUtil = new ToolUtil(); diff --git a/src/weaver/aiyh_pcn/workflow_to_customer/utils/Utils.java b/src/weaver/aiyh_pcn/workflow_to_customer/utils/Utils.java index ab2b9cc..57556ee 100644 --- a/src/weaver/aiyh_pcn/workflow_to_customer/utils/Utils.java +++ b/src/weaver/aiyh_pcn/workflow_to_customer/utils/Utils.java @@ -10,7 +10,7 @@ import java.util.Objects; /** * @author EBU7-dev1-ayh * @create 2021/8/10 0010 10:42 - * dao class + * mybatisTest.dao class */ diff --git a/test/mybatisTest/MybatisTest.java b/test/mybatisTest/MybatisTest.java new file mode 100644 index 0000000..4c3dc04 --- /dev/null +++ b/test/mybatisTest/MybatisTest.java @@ -0,0 +1,44 @@ +package mybatisTest; + +import aiyh.utils.MybatisUtil; +import baseTest.BaseTest; +import mybatisTest.dao.ITestDAO; +import mybatisTest.entity.License; +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.SqlSessionFactoryBuilder; +import org.apache.ibatis.session.SqlSessionManager; +import org.junit.Test; + +import java.io.Reader; + +/** + * @author EBU7-dev1-ayh + * create 2021/12/14 0014 12:52 + */ + + +public class MybatisTest extends BaseTest { + //查询 + @Test + public void testName() throws Exception{ + SqlSession session = null; + Reader resourceAsReader = Resources.getResourceAsReader("WEB-INF/test-mybatis-config.xml"); + SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsReader); + session = build.openSession(); + ITestDAO mapper = session.getMapper(ITestDAO.class); +// Map map = mapper.selectOne(); +// System.err.println(map); + session.close(); + } + + @Test + public void test(){ + SqlSessionManager sessionManager = MybatisUtil.getSessionManager("test-mybatis-config.xml"); + ITestDAO mapper = sessionManager.getMapper(ITestDAO.class); + License license = mapper.selectOne(); + System.out.println(license); + } + +}