标签:find ror XML static 一级缓存 size 共享 统一 UI
value: 用户信息。
,还要在具体的mapper.xml中开启二级缓存,即:
<mapper namespace="com.shyroke.mapper.OrderMapper"> <cache /> </mapper>
public static void main(String[] args) throws IOException { String resource = "resource/mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream); SqlSession session = sessionFactory.openSession(); SqlSession session2 = sessionFactory.openSession(); OrderMapper orderMapper = session.getMapper(OrderMapper.class); OrderMapper orderMapper2 = session2.getMapper(OrderMapper.class); Customer customer=orderMapper.findCustomerById(1); System.out.println(customer); //关闭session,将信息写入二级缓存中 session.close(); Customer customer2=orderMapper2.findCustomerById(1); System.out.println(customer2); }
标签:find ror XML static 一级缓存 size 共享 统一 UI
原文地址:http://www.cnblogs.com/shyroke/p/7609915.html