《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《
@Test
public void insertUserTest() throws IOException{
String resource = "SqlMapConfig.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
SqlSession sqlSession = sqlSessionFactory.openSession();
User user = new User();
user.setAddress("寿光");
user.setBirthday(new Date());
user.setSex("1");
user.setUsername("隋伟");
sqlSession.insert("test.insertUser", user);
sqlSession.commit();
sqlSession.close();
}
《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《
insert into user(id,username,birthday,sex,address) value(#{id},#{username},#{birthday},#{sex},#{address})
一运行就说sources not found
检查有没有在SqlMapConfig.xml中加载UserMapper.xml文件:
再看偶没有在映射文件中写错~
你的mapper文件配置了吗
数据源配置了吗。
jdbc那一块集成到mybatis了没?