mybatis测试类的链接规范1.0

  public static void main(String[] args) throws Exception {
    		//获取xml文件的路径
    		String resource = "config/SqlMapConfig.xml";
    		//配置路径
    		InputStream inputStream = Resources.getResourceAsStream(resource);
    		
    		//创建SqlSessionFactory
    		SqlSessionFactory sqlFactory = 
    				new SqlSessionFactoryBuilder().build(inputStream);
    		//创建SqlSession
    		SqlSession sqlSession = sqlFactory.openSession();
    		
    		/*
    		 * 你想做的操作
    		 * */
    		 user user1=sqlSession.selectOne("user.getUserById",1);
    		 system.print.out(user);
    		
    		sqlSession.close();
    	}

猜你喜欢

转载自blog.csdn.net/weixin_42909272/article/details/85001349