【问题标题】:Ibatis - Error creating bean with name sqlMapClient [duplicate]Ibatis - 创建名为 sqlMapClient 的 bean 时出错 [重复]
【发布时间】:2016-02-24 15:13:19
【问题描述】:

我正在尝试将大型企业应用程序从 spring 2.0.8 迁移到 3.2。我遵循了迁移指南,并且已经编译了项目的所有文件。但是在开始 Spring Context 时我得到了错误。

[24/02/16 13:50:26:524 CET] 0000000d ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
                             org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionInterceptor' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'usuariosBO' while setting bean property 'servicio'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usuariosBO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'usuariosDAO' while setting bean property 'usuariosDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usuariosDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sqlMapClient' while setting bean property 'sqlMapClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com/ibatis/sqlmap/engine/builder/xml/SqlMapConfigParser.parse(Ljava/io/InputStream;Ljava/util/Properties;)Lcom/ibatis/sqlmap/client/SqlMapClient;

和(我也反编译了iBatis jar,发现类SqlMapConfigParse中的方法解析)

Caused by: java.lang.NoSuchMethodError: com/ibatis/sqlmap/engine/builder/xml/SqlMapConfigParser.parse(Ljava/io/InputStream;Ljava/util/Properties;)Lcom/ibatis/sqlmap/client/SqlMapClient;

我的 applicationContext.xml 位于 WEB-INF

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

<bean id="sessionInterceptor" class="app.web.filters.SessionInterceptor">
    <property name="active" value="true"/>
    <property name="intentosConexion" value="2"/>
    <property name="servicio" ref="usuariosBO"/>    
</bean>


<bean id="cacheInterceptor" class="app.web.filters.CacheInterceptor">
    <property name="active" value="true"/>
</bean>

<bean id="localeInterceptor" class="app.web.filters.LocaleInterceptor">
    <property name="active" value="true"/>
</bean>

<bean id="urlInterceptor" class="app.web.filters.UrlInterceptor">
    <property name="active" value="true"/>
    <property name="servicio" ref="usuariosBO"/>
</bean>


<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="alwaysUseMessageFormat" value="true"/>
    <property name="useCodeAsDefaultMessage" value="true"/>
    <property name="defaultEncoding" value="ISO-8859-1"/>
    <property name="basenames">
        <list>
            <value>WEB-INF/classes/app/utils/message</value>
            <value>WEB-INF/classes/app/utils/reports/gor</value>
        </list>
    </property>
</bean>

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>


<bean id="validatorFactory" class="org.springmodules.validation.commons.DefaultValidatorFactory">
    <property name="validationConfigLocations">
      <list>
        <value>WEB-INF/utils/validator-rules.xml</value>
        <value>WEB-INF/validation.xml</value>
      </list>
    </property>
</bean>

<bean id="beanValidator" class="org.springmodules.validation.commons.DefaultBeanValidator">
    <property name="validatorFactory" ref="validatorFactory"/>
</bean>

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>WEB-INF/tiles-defs.xml</value>
        </list>
    </property>
</bean>

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>jdbc/HSGRTE</value> 
    </property>
</bean>

<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <property name="configLocation" value="WEB-INF/sqlmap-config.xml"/>
    <property name="dataSource" ref="dataSource"/>
</bean>

<bean id="usuariosBO" class="app.service.impl.UsuariosImplBO">
    <property name="usuariosDAO" ref="usuariosDAO"/>
</bean>

<bean id="usuariosDAO" class="app.repository.impl.UsuariosImplDAO">
    <property name="sqlMapClient" ref="sqlMapClient"/>
</bean>

<bean name="exampleAfterAdvice" class="app.aops.ExampleAfterAdvice">
</bean> 
<bean name="gestionEnviosAfterAdvice" class="app.aops.GestionEnviosAfterAdvice">
    <property name="applicationContextBean" ref="applicationContextBean"/>
</bean>


<bean name="applicationContextBean" class="app.domain.ApplicationContextBean">
</bean>

位于WEB-INF中的sqlmap-config.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"  "utils/sql-map-config-2.dtd">
<sqlMapConfig>

<settings
        cacheModelsEnabled="true"
        useStatementNamespaces="true"
        maxRequests="512"
        maxSessions="128"
        maxTransactions="32"
        lazyLoadingEnabled="false"
        enhancementEnabled="true"/>

<typeHandler javaType="java.sql.ResultSet"
                     callback="com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.RefTypeHandler"/>


<sqlMap resource="app/maps/ListaDistribucion.xml"/>
<sqlMap resource="app/maps/MapaCobertura.xml"/>
<sqlMap resource="app/maps/Clientes.xml"/>
<sqlMap resource="app/maps/Usuarios.xml"/>

</sqlMapConfig>

应用程序有以下 jar:

  • ibatis2-sqlmap-2.1.7.597
  • ibatis2-common-2.1.7.597

所有必需的 spring 依赖,版本 - 3.2.16.RELEASE

服务器是 websphere 7.0

我猜是iBatis的问题,但我看不出是什么问题。

我正在寻求帮助,请问有什么想法吗?

提前致谢。

【问题讨论】:

    标签: java spring hibernate spring-mvc ibatis


    【解决方案1】:

    解决了。问题是 spring-orm-3.2.16.RELEASE,SqlMapClientFactoryBean 类有不同的方法“buildSqlMapClient”。

    解决方法:将jar替换为spring-orm-2.5.jar

    如果您知道其他解决方案,请告诉我。

    【讨论】:

      猜你喜欢
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      • 2021-11-28
      • 2020-10-03
      • 2019-08-28
      • 2015-03-18
      • 2021-03-17
      • 2021-06-18
      相关资源
      最近更新 更多