• eclipse使用(一)


      使用eclipse时,编写对象的返回值非常麻烦,而使用返回值快捷键可以简化这一过程

    • 第一种 Alt+shift+L
      • 将光标放在有返回值的代码句的分号后面;
        Resources.getResourceAsStream("mybatis.xml");
        
        new SqlSessionFactoryBuilder().build(resourceAsStream);
        
        factory.openSession();
        
      • 按住Alt+Shift+L键,会弹出对话框,输入变量的名字,点击OK即可;

    InputStream resourceAsStream = Resources.getResourceAsStream("mybatis.xml");
    
    SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(resourceAsStream);
    
    SqlSession session = factory.openSession();
    • 第二种 Ctrl+1
      • 将光标放置在有返回值代码句那一行上(分号前后都行);
        Resources.getResourceAsStream("mybatis.xml");
        
        new SqlSessionFactoryBuilder().build(resourceAsStream);
        
        factory.openSession();
      • 选择Assign statement to new local variable : 生成局部变量;
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatis.xml");
        
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        
        SqlSession session = factory.openSession();

         

      • 选择Assign statement to new field : 生成全局变量;
        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 com.bjm.pojo.People;
        
        public class Test {
        	private static SqlSessionFactory factory;
        	private static InputStream resourceAsStream;
        	private static SqlSession openSession;
        
        	public static void main(String[] args) throws IOException{
        		resourceAsStream = Resources.getResourceAsStream("mybatis.xml");
        		factory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        		openSession = factory.openSession();
        		List<People> selectList = openSession.selectList("com.bjm.mapper.selAll");
        		
        		for (People people : selectList) {
        			System.out.println(people.toString());
        		}openSession.close();
        	}
        }
        
  • 相关阅读:
    H5软键盘搜索
    ios顺畅滑动
    自定义滚动条样式
    mockjs模拟数据(本地版)
    移动端防止窗体滚动
    css超出部分省略号
    H5自带的type=date或者month等日期控件移动端显示placeholder
    判断是否在微信内打开
    滚动加载数据
    activemq 5.6 连接池的内存泄露问题
  • 原文地址:https://www.cnblogs.com/bjm1/p/10247269.html
Copyright © 2020-2023  润新知