spring-ibatis 配置的典型模式,若没有 default-lazy-init="true" 这个设置,将抛出下面异常
缺少 default-lazy-init="true" 设置时候的异常
严重: 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 'sqlMapClientDaoSupport' defined in class path resource [applicationContext-jeaf-amp.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.ibatis.support.SqlMapClientDaoSupport]: Is it an abstract class?; nested exception is java.lang.InstantiationException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClientDaoSupport' defined in class path resource [applicationContext-jeaf-amp.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.ibatis.support.SqlMapClientDaoSupport]: Is it an abstract class?; nested exception is java.lang.InstantiationException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"
default-lazy-init="true"> <!-- 缺了 default-lazy-init="true" 这个设置,sqlMapClientDaoSupport 定义处会出错 -->
<!-- 定义受环境影响易变的变量 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath*:/jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialSize" value="1" />
<property name="maxActive" value="2" />
<property name="maxIdle" value="1" />
<property name="maxWait" value="1000" />
<property name="poolPreparedStatements" value="true" />
<property name="defaultAutoCommit" value="false" />
<property name="validationQuery" value="select 1 from dual"/>
<property name="testOnBorrow" value="true"/>
<property name="testWhileIdle" value="true"/>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="configLocation">
<value>classpath:ibatis/sqlMapConfig-jeaf-core.xml</value>
</property>
</bean>
<bean id="sqlMapClientDaoSupport" class="org.springframework.orm.ibatis.support.SqlMapClientDaoSupport">
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
<bean id="jempSysLoginDAO" class="com.skymount.jeaf.core.dao.impl.JempSysLoginDAOImpl" parent="sqlMapClientDaoSupport" />
<bean id="jempSysMenuDAO" class="com.skymount.jeaf.core.dao.impl.JempSysMenuDAOImpl" parent="sqlMapClientDaoSupport" />
<bean id="jempSysOperationDAO" class="com.skymount.jeaf.core.dao.impl.JempSysOperationDAOImpl" parent="sqlMapClientDaoSupport" />
<bean id="jempSysOperLogDAO" class="com.skymount.jeaf.core.dao.impl.JempSysOperLogDAOImpl" parent="sqlMapClientDaoSupport" />
<bean id="jempSysOperResDAO" class="com.skymount.jeaf.core.dao.impl.JempSysOperResDAOImpl" parent="sqlMapClientDaoSupport" />
</beans>
3245

被折叠的 条评论
为什么被折叠?



