spring+mybatis集成问题
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="#{jdbc.driverClassName}"></property>
<property name="url" value="#{jdbc.url}"></property>
<property name="username" value="#{jdbc.username}"></property>
<property name="password" value="#{jdbc.password}"></property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:com/xiaoxiao/xml/MapConfig.xml" />
<property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="mapperFactoryBean" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.xiaoxiao.services.StudentServeice" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
这个是我的配置文件,报的异常总是
2012-06-05 10:35:42,474 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed;
nested exception is java.lang.reflect.MalformedParameterizedTypeException
------解决方案--------------------
你的spring版本是多少?换到3.0以上的试试?
------解决方案--------------------
Java code
<!--根据dataSource和configLocation创建一个SqlMapClient -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>/WEB-INF/classes/sql-map-config.xml</value>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>