spring 3.0.6和mybatis 3.1.1集成Mapped Statements collection does not contai
项目结构:
UserMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.nettime.shop.userManager.dao.UserMapper">
<resultMap id="BaseResultMap" type="com.nettime.shop.userManager.model.User">
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
</resultMap>
<insert id="insert" parameterType="com.nettime.shop.userManager.model.User">
insert into shopUser(id, username, password)
values (#{id,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
#{password,jdbcType=username})
</insert>
</mapper>
UserMapper.java
package com.nettime.shop.userManager.dao;
import com.nettime.shop.userManager.model.User;
public inte易做图ce UserMapper {
public void insert(User u);
}
applicationContext.xml
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property name="username" value="system" />
<property name="password" value="123456" />
</bean>
<!-- myBatis文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:com/nettime/shop/*.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.nettime.shop" />
<!-- http://louis86525.iteye.com/blog/1436320
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"
/>-->
</bean>
</beans>
我在调用UserMapper的insert方法时报错,错误堆栈为:
java
mybatis
spring
exception
mapper
--------------------编程问答--------------------
pplicationContext.xml 里边没见你把service 以及dao注入啊,
--------------------编程问答--------------------
我是使用注解来配置
补充:Java , Java EE