标签:rjava result select 数据 pen url class cep log
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!--SQL日志-->
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
<!-- 配置环境 -->
<environments default="mysql">
<!-- 配置mysql的环境-->
<environment id="mysql">
<!-- 配置事务的类型-->
<transactionManager type="JDBC"></transactionManager>
<!-- 配置数据源(连接池) -->
<dataSource type="POOLED">
<!-- 配置连接数据库的4个基本信息 -->
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/kdb1"/>
<property name="username" value="root"/>
<property name="password" value="rootpy2018"/>
</dataSource>
</environment>
</environments>
<!-- Mapper 映射文件 -->
<mappers>
<mapper resource="cn/ccut/mapper/UserMapper.xml"></mapper>
</mappers>
</configuration>
public interface UserMapper {
List<User> findAllUser();
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.ccut.mapper.UserMapper">
<select id="findAllUser" resultType="cn.ccut.domain.User">
select * from user
</select>
</mapper>
public class TestA {
@Test
public void sta() throws IOException {
String path="mybatis-config.xml";
// FileInputStream fileInputStream = new FileInputStream(path);
InputStream in = Resources.getResourceAsStream(path);
SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(in);
SqlSession sqlSession = sessionFactory.openSession();
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
System.out.println(mapper.findAllUser());
}
}
标签:rjava result select 数据 pen url class cep log
原文地址:https://www.cnblogs.com/zhenqk/p/13551954.html