配置和使用mybatis select * from userinfo select * from userinfo where id=#{id} delete userinfo where id=#{id} package org.jxnd.test;import java.io.IOException;import java.io.InputStream;import java.util.List;import org.apache.ibatis.io
package org.jxnd.test; import java.io.IOException; import java.io.InputStream; import java.util.List; 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.jxnd.bean.UserInfo; public class Test { public static void main(String[] args) throws Exception { String resource = "mybatis.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); SqlSession session =sqlSessionFactory.openSession(); // session.delete("user.deleteById", 15); System.out.println(session.selectOne("user.getUserById",15)); // List delete userinfo where id=#{id} list=session.selectList("user.getAllUsers"); // for (UserInfo userInfo : list) { // System.out.println(userInfo); // } session.commit(); session.close(); } }