在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>
这样文件就解决了,浪费了好长时间!
分享到:
相关推荐
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"> <value>classpath:SqlMapConfig.xml </bean> <bean id="dao" class="org....
部分配置代码,所有代码都有,很全 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.... <property name="sqlMapClient" ref="sqlMapClient"> </bean>
throw new RuntimeException("Error initializing SqlMapConfig class. Cause: " + e); } ``` 在iBatis中,插入新记录后获取自增长ID值是非常常见的需求。`SqlMapClient`提供了一种方式,通过`<selectKey>`标签来...
通过调用`SqlMapClient.startTransaction()`开启事务,`SqlMapClient.commitTransaction()`提交事务,或者`SqlMapClient.rollbackTransaction()`回滚事务。 6. **异常处理**: 在初始化SqlMapClient或执行数据库...
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:dataSource-ref="dataSourceProxy"> <property name="configLocation"> <value>classpath:SqlMapConfig.xml...
<property name="sqlMapClient" ref="sqlMapClient"/> </bean> <bean id="studentDaoSqlMap" class="cn.hsw.dao.StudentDaoSqlMap"> <property name="sqlMapClientTemplate" ref="sqlMapClientTemplate"/> </bean...
<property name="sqlMapClient" ref="sqlMapClient" /> </bean> ``` - **重要配置项解释**: - `name` 和 `class`:指定控制器类。 - `dao`:注入DAO层对象。 - `methodNameResolver`:用于解析方法名的Bean。 ...
<property name="sqlMapClient" ref="sqlMapClient"/> </bean> <!-- 配置 transactionManager事物管理--> <bean id="transactionManager" class="org.springframework.jdbc.datasource....
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <!-- 通过文件路径指定iBatis配置文件 --> <property name="configLocation"> <value>/WEB-INF/SqlMapConfig.xml ...
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" scope="singleton"> <property name="configLocation"> <value>classpath:SqlMapConfig.xml <property name=...
<property name="sqlMapClient" ref="sqlMapClient"/> </bean> ``` 最后,定义了一个`PersonServices` Bean,它负责处理业务逻辑,并通过注入`sqlMapClient`来操作数据库。 **3. jdbc.properties** 这是一个简单...
<forward name="error" path="/jsp/error.jsp"/> ``` 这里,"/login"是请求路径,`com.example.LoginAction`是处理该请求的Action类,"loginForm"是ActionForm的名称,"success"和"error"是两种可能的转发结果。 ...
<property name="sqlMapClient" ref="sqlMapClient"/> </bean> ``` 在这个配置中,`DynamicDataSource`作为所有数据源的父类,`sqlMapClient`指向`DynamicDataSource`,这样所有使用`sqlMapClient`的DAO类,如`...
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mapperLocations" value="classpath*:Student.xml...
<property name="sqlMapClient" ref="sqlMapClient" /> </bean> ``` 接着,我们需要创建iBATIS的SQL映射文件(如`sqlMapConfig.xml`),在这个文件中,我们将定义数据库的SQL语句。例如,我们可以定义一个用户查询...
<property name="sqlMapClient" ref="sqlMapClient" /> </bean> ``` 并创建抽象的`SqlMapClientDaoSupport`,作为其他DAO类的基类,注入`sqlMapClientTemplate`: ```xml <bean id="sqlMapClientDaoSupport" ...
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"> <value>classpath:sqlMapConfig.xml </bean> ``` 其中`sqlMapConfig.xml`是...
<bean id="sqlMapClient" class="org.mybatis.spring.SqlMapClientFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:SqlMapConfig.xml"/> </...
由于iBatis 3将SqlMapClient替换为SqlSessionFactory,所以我们要创建一个`SqlSessionFactoryBean`: ```xml <!-- iBatis SqlSessionFactory配置 --> <bean id="sqlSessionFactory" class="org.springframework....
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 ...