dev
IT-xiaoXiong 2021-12-16 15:15:34 +08:00
parent 2461fb044c
commit 705da8204f
6 changed files with 136 additions and 135 deletions

14
pom.xml
View File

@ -46,6 +46,7 @@
<!-- <organization></organization>--> <!-- <organization></organization>-->
<properties> <properties>
<project.build.resource.test.mapper>mybatisTest/mapper</project.build.resource.test.mapper>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<java.version>1.8</java.version> <java.version>1.8</java.version>
@ -100,15 +101,10 @@
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<!-- <resources>--> <resources>
<!-- <resource>--> </resources>
<!-- <directory>test/mybatisTest</directory>--> <testResources>
<!-- <includes>--> </testResources>
<!-- <include>**/*.xml</include>-->
<!-- </includes>-->
<!-- <filtering>true</filtering>-->
<!-- </resource>-->
<!-- </resources>-->
</build> </build>
</project> </project>

View File

@ -2,8 +2,8 @@ package mybatisTest;
import aiyh.utils.MybatisUtil; import aiyh.utils.MybatisUtil;
import baseTest.BaseTest; import baseTest.BaseTest;
import mybatisTest.dao.ITestDAO;
import mybatisTest.entity.License; import mybatisTest.entity.License;
import mybatisTest.mapper.ITestMapper;
import org.apache.ibatis.io.Resources; import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
@ -27,7 +27,7 @@ public class MybatisTest extends BaseTest {
Reader resourceAsReader = Resources.getResourceAsReader("WEB-INF/test-mybatis-config.xml"); Reader resourceAsReader = Resources.getResourceAsReader("WEB-INF/test-mybatis-config.xml");
SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsReader); SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsReader);
session = build.openSession(); session = build.openSession();
ITestDAO mapper = session.getMapper(ITestDAO.class); ITestMapper mapper = session.getMapper(ITestMapper.class);
// Map<String, String> map = mapper.selectOne(); // Map<String, String> map = mapper.selectOne();
// System.err.println(map); // System.err.println(map);
session.close(); session.close();
@ -36,7 +36,7 @@ public class MybatisTest extends BaseTest {
@Test @Test
public void test(){ public void test(){
SqlSessionManager sessionManager = MybatisUtil.getSessionManager("test-mybatis-config.xml"); SqlSessionManager sessionManager = MybatisUtil.getSessionManager("test-mybatis-config.xml");
ITestDAO mapper = sessionManager.getMapper(ITestDAO.class); ITestMapper mapper = sessionManager.getMapper(ITestMapper.class);
License license = mapper.selectOne(); License license = mapper.selectOne();
System.out.println(license); System.out.println(license);
} }

View File

@ -1,15 +0,0 @@
package mybatisTest.dao;
import mybatisTest.entity.License;
import java.util.Map;
/**
* @author EBU7-dev1-ayh
* create 2021/12/14 0014 13:20
*/
public interface ITestDAO {
License selectOne();
}

View File

@ -0,0 +1,12 @@
package mybatisTest.mapper;
import mybatisTest.entity.License;
/**
* @author @author EBU7-dev1-ay
* create 2021/12/16 0016 13:33
*/
public interface ITestMapper {
License selectOne();
}

View File

@ -0,0 +1,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mybatisTest.mapper.ITestMapper">
<select id="selectOne" resultType="License">
select companyname company_name,license,expiredate expire_date,CVERSION c_version from license;
</select>
</mapper>

View File

@ -24,6 +24,7 @@
</environments> </environments>
<mappers> <mappers>
<mapper resource="WEB-INF/mapper/test-mapper/ItestDAO.xml"/> <!-- <mapper resource="WEB-INF/mapper/test-mapper/ItestDAO.xml"/>-->
<package name="mybatisTest.mapper"/>
</mappers> </mappers>
</configuration> </configuration>