Mybatis 사용자 정의 페이지 플러그 인 후 오류 처리

2211 단어 Mybatis
전단 시간 에 pageHelper 작가 의 Mybatis 페이지 플러그 인 을 모방 하여 스스로 수정 하고 최적화 시 켰 습 니 다. 프로젝트 에서 실 행 된 후에 오 류 를 보고 합 니 다. 오 류 는 다음 과 같 습 니 다.
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error opening session.  Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection)
### Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection)
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:100)

사실 신문 의 잘못된 힌트 를 자세히 보고 소스 코드 에 쫓 아가 보면 그 이 유 를 알 수 있 습 니 다. 비교적 새 롭 거나 최신 MyBatis 를 사 용 했 기 때 문 입 니 다. jar 가방, 나의 차단기 코드 는 비교적 오래된 쓰기 입 니 다.MyBatis 의 새로운 jar 패키지 에서 StatementHandler 의 prepare 방법 은 두 가지 인자 가 있 습 니 다. 다음 과 같 습 니 다: Statement prepare(Connection connection, Integer transaction Timeout), 내 차단기 코드 에는 인자 가 하나 밖 에 없어 서 가 져 올 수 없습니다.해결 방법 이 나 왔 습 니 다. 페이지 차단기 규칙 에 Integer. class 인 자 를 추가 해 야 합 니 다.다음 과 같다.

@Intercepts ({ @Signature (type=StatementHandler. class ,method= "prepare" ,args={Connection. class , Integer. class   })})
이상 은 나중에 사람들 이 쉽게 찾 아 볼 수 있 도록 자신의 페이지 플러그 인의 오류 과정 을 기록 하 는 것 입 니 다 ~

좋은 웹페이지 즐겨찾기