1
如果沒有彈簧,一個MyBatis的映射器使用這樣的:如果使用spring來注入映射器,mybatis會話何時打開?
try (SqlSession session = sqlSessionFactory.openSession()) {
Mapper mapper = session.getMapper(Mapper.class);
result = mapper.select(...);
}
return result;
在使用的彈簧,映射器使用這樣的:
@Inject
private Mapper mapper;
public Response work() {
result = mapper.select();
return result;
}
我的問題是當在會話中打開?