测试_加载本地配置文件_根据参数查询违章信息(数据库查询)
@Test
public void TestfindViolation() {
String resource = "com/gac/violation/resource/test/conf.xml";
InputStream is = BusinessServiceTest.class.getClassLoader().getResourceAsStream(resource);
// 构建sqlSession的工厂
SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is);
// 创建能执行映射文件中sql的sqlSession
SqlSession session = sessionFactory.openSession();
/**
* 映射sql的标识字符串, me.gacl.mapping.userMapper是userMapper.xml文件中mapper标签的namespace属性的值,
* getUser是select标签的id属性值,通过select标签的id属性值就可以找到要执行的SQL
*/
String statement = "com.gac.violation.dao.ViolationEntityMapper.selectByExample";// 映射sql的标识字符串
ViolationEntityExample example = new ViolationEntityExample();
example.createCriteria().andCarNoEqualTo("111");
List<ViolationEntity> user = session.selectList(statement, example);
System.out.println(user);
}