`

Error creating bean with name 'sqlMapClient' defined in ServletContext resource

阅读更多

在spring   3.0.5.RELEASE  版本下,

 

 

ibatis 的版本为  

<dependency>

<groupId>com.ibatis</groupId>

<artifactId>ibatis2-sqlmap</artifactId>

<version>2.1.7.597</version>

</dependency>

 

tomcat启动出错 ,错误信息如下:  (出错后,先查看tomcat的logs目录下的catalina.log文件和localhost.log文件

 

在log中输出 : startup failed due to previous errors

 

 

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in ServletContext resource [/WEB-INF/classes/dataAccessContext.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;

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)

at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)

at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

at java.util.concurrent.FutureTask.run(FutureTask.java:166)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

at java.lang.Thread.run(Thread.java:722)

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

at org.springframework.orm.ibatis.SqlMapClientFactoryBean.buildSqlMapClient(SqlMapClientFactoryBean.java:338)

at org.springframework.orm.ibatis.SqlMapClientFactoryBean.afterPropertiesSet(SqlMapClientFactoryBean.java:291)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)

... 26 more

 

01, 2012 12:49:02 ÏÂÎç org.apache.catalina.core.ApplicationContext log

 Closing Spring root WebApplicationContext

01, 2012 12:49:03 ÏÂÎç org.apache.catalina.core.ApplicationContext log

Initializing WebApplicationContext for Struts ActionServlet 'action', module ''


错误原因是:ibatis2-sqlmap  版本太低了,接口变化了

解决方法为: 
在pom文件中把    
<!--   版本太低  出错-->
  <dependency>
<groupId>com.ibatis</groupId>
<artifactId>ibatis2-sqlmap</artifactId>
<version>2.1.7.597</version>
</dependency>



换成高版本
   <dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.4.726</version> 
</dependency>


这样文件就解决了,浪费了好长时间!
分享到:
评论

相关推荐

    Spring高版本对ibatis的支持

    &lt;bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"&gt; &lt;property name="configLocation"&gt; &lt;value&gt;classpath:SqlMapConfig.xml &lt;/bean&gt; &lt;bean id="dao" class="org....

    SSI框架整合实例

    部分配置代码,所有代码都有,很全 &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.... &lt;property name="sqlMapClient" ref="sqlMapClient"&gt; &lt;/bean&gt;

    SqlMapClient对象.docx

    throw new RuntimeException("Error initializing SqlMapConfig class. Cause: " + e); } ``` 在iBatis中,插入新记录后获取自增长ID值是非常常见的需求。`SqlMapClient`提供了一种方式,通过`&lt;selectKey&gt;`标签来...

    SqlMapClient对象.pdf

    通过调用`SqlMapClient.startTransaction()`开启事务,`SqlMapClient.commitTransaction()`提交事务,或者`SqlMapClient.rollbackTransaction()`回滚事务。 6. **异常处理**: 在初始化SqlMapClient或执行数据库...

    spring applicationContext 配置文件

    &lt;bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:dataSource-ref="dataSourceProxy"&gt; &lt;property name="configLocation"&gt; &lt;value&gt;classpath:SqlMapConfig.xml...

    ibatis整合spring

    &lt;property name="sqlMapClient" ref="sqlMapClient"/&gt; &lt;/bean&gt; &lt;bean id="studentDaoSqlMap" class="cn.hsw.dao.StudentDaoSqlMap"&gt; &lt;property name="sqlMapClientTemplate" ref="sqlMapClientTemplate"/&gt; &lt;/bean...

    Spring整合ibatis

    &lt;property name="sqlMapClient" ref="sqlMapClient" /&gt; &lt;/bean&gt; ``` - **重要配置项解释**: - `name` 和 `class`:指定控制器类。 - `dao`:注入DAO层对象。 - `methodNameResolver`:用于解析方法名的Bean。 ...

    springmvc-ibatis

    &lt;property name="sqlMapClient" ref="sqlMapClient"/&gt; &lt;/bean&gt; &lt;!-- 配置 transactionManager事物管理--&gt; &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource....

    SPRING IBATIS 保留IBATIS事务的配置方式

    &lt;bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"&gt; &lt;!-- 通过文件路径指定iBatis配置文件 --&gt; &lt;property name="configLocation"&gt; &lt;value&gt;/WEB-INF/SqlMapConfig.xml ...

    struts+spring+ibaits配置详解

    &lt;bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" scope="singleton"&gt; &lt;property name="configLocation"&gt; &lt;value&gt;classpath:SqlMapConfig.xml &lt;property name=...

    Spring+Webwork+iBatis 组合实例

    &lt;property name="sqlMapClient" ref="sqlMapClient"/&gt; &lt;/bean&gt; ``` 最后,定义了一个`PersonServices` Bean,它负责处理业务逻辑,并通过注入`sqlMapClient`来操作数据库。 **3. jdbc.properties** 这是一个简单...

    spring+ibaitis+struts配置文件实例

    &lt;forward name="error" path="/jsp/error.jsp"/&gt; ``` 这里,"/login"是请求路径,`com.example.LoginAction`是处理该请求的Action类,"loginForm"是ActionForm的名称,"success"和"error"是两种可能的转发结果。 ...

    Spring多数据源解决方案

    &lt;property name="sqlMapClient" ref="sqlMapClient"/&gt; &lt;/bean&gt; ``` 在这个配置中,`DynamicDataSource`作为所有数据源的父类,`sqlMapClient`指向`DynamicDataSource`,这样所有使用`sqlMapClient`的DAO类,如`...

    ibatis+spring完全整合

    &lt;bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="mapperLocations" value="classpath*:Student.xml...

    Spring与iBATIS的集成示例代码

    &lt;property name="sqlMapClient" ref="sqlMapClient" /&gt; &lt;/bean&gt; ``` 接着,我们需要创建iBATIS的SQL映射文件(如`sqlMapConfig.xml`),在这个文件中,我们将定义数据库的SQL语句。例如,我们可以定义一个用户查询...

    WEB项目-集成Flex3+BlazeDS3.2+Spring2.5.6+iBatis2.3.4

    &lt;property name="sqlMapClient" ref="sqlMapClient" /&gt; &lt;/bean&gt; ``` 并创建抽象的`SqlMapClientDaoSupport`,作为其他DAO类的基类,注入`sqlMapClientTemplate`: ```xml &lt;bean id="sqlMapClientDaoSupport" ...

    Spring+iBatis整合详解

    &lt;bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"&gt; &lt;property name="configLocation"&gt; &lt;value&gt;classpath:sqlMapConfig.xml &lt;/bean&gt; ``` 其中`sqlMapConfig.xml`是...

    ibatis与spring整合

    &lt;bean id="sqlMapClient" class="org.mybatis.spring.SqlMapClientFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;property name="configLocation" value="classpath:SqlMapConfig.xml"/&gt; &lt;/...

    Spring 3.0 整合 iBatis 3 Beta10 配置

    由于iBatis 3将SqlMapClient替换为SqlSessionFactory,所以我们要创建一个`SqlSessionFactoryBean`: ```xml &lt;!-- iBatis SqlSessionFactory配置 --&gt; &lt;bean id="sqlSessionFactory" class="org.springframework....

    Spring中文帮助文档

    2.3.3. 对bean命名pointcut( bean name pointcut element)的支持 2.3.4. 对AspectJ装载时织入(AspectJ load-time weaving)的支持 2.4. 中间层 2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. 对Websphere ...

Global site tag (gtag.js) - Google Analytics