2016-07-25 13 views
0

私はMybatisを使用してインターセプタを作成しましたが、コンソールを実行すると、StatementHandlerクラスに "prepare"メソッドがありません。私に必要なことは他にありますか?インタフェースorg.apache.ibatis.executor.statement.StatementHandlerのメソッドprepareが見つかりませんでした

これは注釈です:

@Intercepts({ @Signature(type = StatementHandler.class, method = "prepare", args = { Connection.class, Integer.class }) }) 
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(com.mysql.jdbc.Connection, java.lang.Integer) 
### 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(com.mysql.jdbc.Connection, java.lang.Integer) 
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:100) 
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:47) 
    com.fj.db.DBAccess.getSqlSession(DBAccess.java:30) 
    com.fj.dao.MessageDao.count(MessageDao.java:121) 
    com.fj.service.QueryService.queryMessageList(QueryService.java:34) 
    com.fj.servlet.ListServlet.doGet(ListServlet.java:46) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
root 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(com.mysql.jdbc.Connection, java.lang.Integer) 
    org.apache.ibatis.plugin.Plugin.getSignatureMap(Plugin.java:87) 
    org.apache.ibatis.plugin.Plugin.wrap(Plugin.java:44) 
    com.fj.interceptor.PageInterceptor.plugin(PageInterceptor.java:121) 
org.apache.ibatis.plugin.InterceptorChain.pluginAll(InterceptorChain.java:31) 
org.apache.ibatis.session.Configuration.newExecutor(Configuration.java:553) 
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:96) 
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:47) 
    com.fj.db.DBAccess.getSqlSession(DBAccess.java:30) 
    com.fj.dao.MessageDao.count(MessageDao.java:121) 
    com.fj.service.QueryService.queryMessageList(QueryService.java:34) 
    com.fj.servlet.ListServlet.doGet(ListServlet.java:46) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
root cause 
java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(com.mysql.jdbc.Connection, java.lang.Integer) 
    java.lang.Class.getMethod(Class.java:1786) 
    org.apache.ibatis.plugin.Plugin.getSignatureMap(Plugin.java:84) 
    org.apache.ibatis.plugin.Plugin.wrap(Plugin.java:44) 
    com.fj.interceptor.PageInterceptor.plugin(PageInterceptor.java:121) 
org.apache.ibatis.plugin.InterceptorChain.pluginAll(InterceptorChain.java:31) 
org.apache.ibatis.session.Configuration.newExecutor(Configuration.java:553) 
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:96) org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:47) 
    com.fj.db.DBAccess.getSqlSession(DBAccess.java:30) 
    com.fj.dao.MessageDao.count(MessageDao.java:121) 
    com.fj.service.QueryService.queryMessageList(QueryService.java:34) 
    com.fj.servlet.ListServlet.doGet(ListServlet.java:46) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
+0

として定義されていますか? –

+0

プログラムの実行時にorg.apache.ibatis.executor.statement.StatementHandlerで "prepare"というメソッドが見つかりません。実際には1つあります。 – Frank

+0

使用しているパラメータのタイプが正しいですか?私が見つけたドキュメントは、メソッドに整数パラメータがあるとは言いません –

答えて

0

あなたのインターセプタの定義が間違っConnectionクラスを使用しています。 com.mysql.jdbc.Connectionを使用していますが、java.sql.Connectionを使用してください。ログ内のこの行あなたStatementHandlerで問題

NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(com.mysql.jdbc.Connection, java.lang.Integer) 

方法の正確な理由を与えるにはドキュメントがありますどのような方法を言うん

java.sql.Statement prepare(java.sql.Connection connection) 
+0

あなたは正しいです!どうもありがとう – Frank

関連する問題