请各位大神看看,springmvc、mybatis整合报错

zkx19960616 2017-07-21 09:39:58
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in URL [file:/E:/JSP/.metadata/.me_tcat/webapps/Test/WEB-INF/classes/spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\JSP\.metadata\.me_tcat\webapps\Test\WEB-INF\classes\com\zkx\mapper\RoleMapper.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.zkx.dao.RoleMapper.BaseResultMap
...全文
113 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zkx19960616 2017-07-21
  • 打赏
  • 举报
回复
配置文件 <!-- 自动扫描 --> <context:component-scan base-package="com.zkx" /> <!-- AOP配置 --> <!-- AOP动态代理 --> <aop:aspectj-autoproxy/> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/zkx/mapper/*.xml"></property> <property name="configLocation" value="classpath:mybatis-config.xml" /> </bean> <!-- <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean>
zkx19960616 2017-07-21
  • 打赏
  • 举报
回复
这是RoleMapper <mapper namespace="com.zkx.dao.RoleMapper"> <resultMap id="BaseResultMap" type="com.zkx.po.Role"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="role_name" jdbcType="VARCHAR" property="roleName" /> </resultMap> <sql id="Base_Column_List"> id, role_name </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from t_role where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from t_role where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="com.zkx.po.Role"> insert into t_role (id, role_name) values (#{id,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="com.zkx.po.Role"> insert into t_role <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="roleName != null"> role_name, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=INTEGER}, </if> <if test="roleName != null"> #{roleName,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.zkx.po.Role"> update t_role <set> <if test="roleName != null"> role_name = #{roleName,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.zkx.po.Role"> update t_role set role_name = #{roleName,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> <resultMap id="BaseResultMap" type="com.zkx.po.Role"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="role_name" jdbcType="VARCHAR" property="roleName" /> </resultMap> <sql id="Base_Column_List"> id, role_name </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from t_role where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from t_role where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="com.zkx.po.Role"> insert into t_role (id, role_name) values (#{id,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="com.zkx.po.Role"> insert into t_role <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="roleName != null"> role_name, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=INTEGER}, </if> <if test="roleName != null"> #{roleName,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.zkx.po.Role"> update t_role <set> <if test="roleName != null"> role_name = #{roleName,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.zkx.po.Role"> update t_role set role_name = #{roleName,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> <resultMap id="BaseResultMap" type="com.zkx.po.Role"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="role_name" jdbcType="VARCHAR" property="roleName" /> </resultMap> <sql id="Base_Column_List"> id, role_name </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from t_role where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from t_role where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="com.zkx.po.Role"> insert into t_role (id, role_name ) values (#{id,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR} ) </insert> <insert id="insertSelective" parameterType="com.zkx.po.Role"> insert into t_role <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="roleName != null"> role_name, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=INTEGER}, </if> <if test="roleName != null"> #{roleName,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.zkx.po.Role"> update t_role <set> <if test="roleName != null"> role_name = #{roleName,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.zkx.po.Role"> update t_role set role_name = #{roleName,jdbcType=VARCHAR}, where id = #{id,jdbcType=INTEGER} </update> </mapper>

50,545

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧