spring、struts、mybatis、Postgresql集成-常见问题

本人在进行spring、struts、mybatis集成过程中出现了很多问题,现记录如下,希望对本人以后及其它遇到类似错误的人提供一些借鉴。

1、Eclipse使用问题
   当选择server(如JBoss)的发布按钮没有反应或者没有变化时,此时应在server上点击右键,然后选择“clean”,此时项目会进行清理和发布。

2、版本问题
   Struts、 Spring、Mybatis版本要匹配,否则会出现莫名奇妙的警告,例如本人开始使用的版本是:struts-2.2.3、spring3.1、 mybatis-3.1.1,出现下面的警告,当将struts的版本换成struts-2.3.7时,警告消失。
WARN  [com.opensymphony.xwork2.util.FileManager] (MSC service thread 1-1) Could not create JarEntryRevision for [vfs:/D:/JBoss/jbossAS711Final/standalone/deployments/SS2MTest.war/WEB-INF/lib/struts2-spring-plugin-2.2.3]!: java.io.FileNotFoundException: vfs:\D:\JBoss\jbossAS711Final\standalone\deployments\SS2MTest.war\WEB-INF\lib\struts2-spring-plugin-2.2.3 (文件名、目录名或卷标语法不正确。)
    at java.util.zip.ZipFile.open(Native Method) [rt.jar:1.6.0_07]
    at java.util.zip.ZipFile.<init>(ZipFile.java:114) [rt.jar:1.6.0_07]
    at java.util.jar.JarFile.<init>(JarFile.java:133) [rt.jar:1.6.0_07]
    at java.util.jar.JarFile.<init>(JarFile.java:97) [rt.jar:1.6.0_07]
    at com.opensymphony.xwork2.util.FileManager$JarEntryRevision.build(FileManager.java:307) [xwork-core-2.2.3.jar:2.2.3]
    at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:145) [xwork-core-2.2.3.jar:2.2.3]
    at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:105) [xwork-core-2.2.3.jar:2.2.3]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:898) [xwork-core-2.2.3.jar:2.2.3]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:154) [xwork-core-2.2.3.jar:2.2.3]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:121) [xwork-core-2.2.3.jar:2.2.3]
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:179) [xwork-core-2.2.3.jar:2.2.3]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) [xwork-core-2.2.3.jar:2.2.3]
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:380) [struts2-core-2.2.3.jar:2.2.3]
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424) [struts2-core-2.2.3.jar:2.2.3]
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) [struts2-core-2.2.3.jar:2.2.3]
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) [struts2-core-2.2.3.jar:2.2.3]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
    at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]

3、Struts错误
ERROR [org.apache.struts2.dispatcher.Dispatcher] (MSC service thread 1-1) Dispatcher initialization failed: Unable to load configuration. - [unknown location]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:71) [xwork-core-2.3.7.jar:2.3.7]
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429) [struts2-core-2.3.7.jar:2.3.7]
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471) [struts2-core-2.3.7.jar:2.3.7]
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) [struts2-core-2.3.7.jar:2.3.7]
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) [struts2-core-2.3.7.jar:2.3.7]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
    at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
    at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:391) [struts2-core-2.3.7.jar:2.3.7]
    at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:362) [struts2-core-2.3.7.jar:2.3.7]
    at org.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:288) [struts2-core-2.3.7.jar:2.3.7]
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215) [xwork-core-2.3.7.jar:2.3.7]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:68) [xwork-core-2.3.7.jar:2.3.7]
    ... 13 more

解决方法:
     <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>  
           <param-name>config</param-name>  
           <param-value>configFiles/struts.xml</param-value>
       </init-param>  
        </filter>

改成

     <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>  
           <param-name>config</param-name>  
           <param-value>platform-web.xml,struts-default.xml,struts-plugin.xml,configFiles/struts.xml</param-value>
       </init-param>  
        </filter>

4、Spring错误
ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-3) Context initialization failed:
org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [configFiles/applicationContext*.xml]; nested exception is java.io.FileNotFoundException: ServletContext resource [/configFiles/] cannot be resolved to URL because it does not exist
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:190) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) [spring-web-2.5.6.jar:2.5.6]
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) [spring-web-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) [spring-context-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) [spring-context-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) [spring-context-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) [spring-web-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) [spring-web-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) [spring-web-2.5.6.jar:2.5.6]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
    at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
Caused by: java.io.FileNotFoundException: ServletContext resource [/configFiles/] cannot be resolved to URL because it does not exist
    at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:130) [spring-web-2.5.6.jar:2.5.6]
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.isJarResource(PathMatchingResourcePatternResolver.java:406) [spring-core-

2.5.6.jar:2.5.6]
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:338) [spring-core-2.5.6.jar:2.5.6]
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:276) [spring-core-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1018) [spring-context-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:177) [spring-beans-2.5.6.jar:2.5.6]
    ... 17 more

解决方法:
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>configFiles/applicationContext*.xml</param-value>
    </context-param>

改成
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:configFiles/applicationContext*.xml</param-value>
    </context-param>
注意:与spring相关的配置文件路径,都要使用classpath*:或其它关键字来限定位置,这与struts不一样。

5、数据库使用Postgresql,连接池使用dbcp,Mybatis使用Postgresql的存储过程返回记录集(以输出参数返回)时提示如下错误:

org.springframework.jdbc.UncategorizedSQLException:
### Error querying database.  Cause: org.postgresql.util.PSQLException: 错误: 游标 "<unnamed portal 1>" 不存在
### The error may involve com.citic.asp.hrms.dao.base.ModelDao.getPage-Inline
### The error occurred while setting parameters
### Cause: org.postgresql.util.PSQLException: 错误: 游标 "<unnamed portal 1>" 不存在
; uncategorized SQLException for SQL []; SQL state [34000]; error code [0]; 错误: 游标 "<unnamed portal 1>" 不存在; nested exception is org.postgresql.util.PSQLException: 错误: 游标 "<unnamed portal 1>" 不存在
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:346)
    at $Proxy5.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:154)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38)
    at $Proxy6.getPage(Unknown Source)
    at com.citic.asp.hrms.service.base.ModelService.getPage(ModelService.java:58)
    at com.citic.asp.hrms.test.base.ModelServiceTest.testGetTest(ModelServiceTest.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.postgresql.util.PSQLException: 错误: 游标 "<unnamed portal 1>" 不存在
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:403)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.execSQLQuery(AbstractJdbc2Connection.java:347)
    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.internalGetObject(AbstractJdbc2ResultSet.java:206)
    at org.postgresql.jdbc3.AbstractJdbc3ResultSet.internalGetObject(AbstractJdbc3ResultSet.java:36)
    at org.postgresql.jdbc4.AbstractJdbc4ResultSet.internalGetObject(AbstractJdbc4ResultSet.java:296)
    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getObject(AbstractJdbc2ResultSet.java:2703)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:454)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:410)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:169)
    at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:42)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:238)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:112)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:60)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338)
    ... 30 more
解决方法:

在DBCP配置文件中增加defaultAutoCommit属性,即将

     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver"></property>
        <property name="url" value="jdbc:postgresql://localhost:5432/CITICHRMS"></property>
        <property name="username" value="postgres"></property>
        <property name="password" value="111111"></property>
    </bean>

改成:

     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver"></property>
        <property name="url" value="jdbc:postgresql://localhost:5432/CITICHRMS"></property>
        <property name="username" value="postgres"></property>
        <property name="password" value="111111"></property>
        <property name="defaultAutoCommit" value="false"></property>
    </bean>

6、数据库使用Postgresql,连接池使用dbcp,Mybatis使用Postgresql的存储过程返回记录集(以输出参数返回)时提示如下错误:

org.springframework.jdbc.BadSqlGrammarException:
### Error querying database.  Cause: org.postgresql.util.PSQLException: 一个 CallableStatement 执行函式后输出的参数类型为 java.sql.Types=1111 值为 2,但是已注册的类型是

java.sql.Types=-10。
### The error may involve com.citic.asp.hrms.dao.base.ModelDao.getPage-Inline
### The error occurred while setting parameters
### Cause: org.postgresql.util.PSQLException: 一个 CallableStatement 执行函式后输出的参数类型为 java.sql.Types=1111 值为 2,但是已注册的类型是 java.sql.Types=-10。
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: 一个 CallableStatement 执行函式后输出的参数类型为 java.sql.Types=1111 值为 2,但是已注册的

类型是 java.sql.Types=-10。
    at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:346)
    at $Proxy5.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:154)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38)
    at $Proxy6.getPage(Unknown Source)
    at com.citic.asp.hrms.service.base.ModelService.getPage(ModelService.java:58)
    at com.citic.asp.hrms.test.base.ModelServiceTest.testGetTest(ModelServiceTest.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.postgresql.util.PSQLException: 一个 CallableStatement 执行函式后输出的参数类型为 java.sql.Types=1111 值为 2,但是已注册的类型是 java.sql.Types=-10。
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:468)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:410)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:169)
    at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:42)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:238)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:112)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:60)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338)
    ... 30 more

此时应更改返回类型:

     <select id="getPage" statementType="CALLABLE" parameterType="HashMap">
       <![CDATA[
           {call p0_sys_model_search(
                 #{filter,mode=IN,jdbcType=VARCHAR},
              #{pageIndex,mode=IN,jdbcType=INTEGER},
              #{recordCountPerPage,mode=IN,jdbcType=INTEGER},
              #{allRecordCount,mode=OUT,jdbcType=INTEGER},
              #{curResult,mode=OUT,jdbcType=CURSOR, javaType=ResultSet, resultMap=modelResultMap}
           )}
       ]]>
     </select>

改成:

     <select id="getPage" statementType="CALLABLE" parameterType="HashMap">
       <![CDATA[
           {call p0_sys_model_search(
                 #{filter,mode=IN,jdbcType=VARCHAR},
              #{pageIndex,mode=IN,jdbcType=INTEGER},
              #{recordCountPerPage,mode=IN,jdbcType=INTEGER},
              #{allRecordCount,mode=OUT,jdbcType=INTEGER},
              #{curResult,mode=OUT,jdbcType=OTHER, javaType=ResultSet, resultMap=modelResultMap}
           )}
       ]]>
     </select>

你可能感兴趣的:(PostgreSQL)