Mapped Statements collection does not contain value for

matrix1984 matrix1984 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
今天搞了个MyBatis+Spring的Demo,本来好好的,不知道是因为执行了mvn install/clean等命令,突然就不行了,哎,太折腾了。

下面贴下spring和myBatis的配置:


appctx-common.xml(省略了beans的namesapce):

<!-- 开启Autowired、Common、Persistence及Required标注的支持 -->
<context:annotation-config />

<context:property-placeholder location="classpath:jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- Connection Info -->
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- Connection Pooling Info -->
<property name="maxActive" value="${dbcp.maxActive}" />
<property name="maxIdle" value="${dbcp.maxIdle}" />
<property name="defaultAutoCommit" value="false" />
<property name="timeBetweenEvictionRunsMillis" value="3600000"/>
<property name="minEvictableIdleTimeMillis" value="3600000"/>
</bean>

<!-- MyBatis integration with Spring as define sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis/mybatis-configuration.xml" />
<!--<property name="mapperLocations" value="classpath*:cn/git/mis/common/model/mapper/*.xml" />-->
</bean>
<!-- 采用扫描指定包的mapper接口,而不是一一定义每个mapper -->
<bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.git.mis.common.model.mapper" />
<!-- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /> -->
</bean>

<!-- transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />


mybatis-configuration.xml:

<configuration>
<typeAliases>
<typeAlias alias="User" type="cn.git.mis.common.model.bean.User" />
</typeAliases>
</configuration>


UserMapper.xml:

<mapper namespace="cn.git.mis.common.model.mapper.UserMapper">
<insert id="insertUser" parameterType="User" useGeneratedKeys="false" keyProperty="id">
insert into T_USER(id,gender,username,password) values(SEQ_USER_ID.nextval,#{gender},#{username},#{password})
</insert>

<select id="getUser" resultType="User" parameterType="map">
select * from T_USER where username = #{username} and password = #{password}
</select>
<select id="getUserById" resultType="User" parameterType="java.lang.Long">
select * from T_USER where id=#{id}
</select>

<update id="updateUser" parameterType="User">
update T_USER set gender=#{gender}, username = #{username} where id = #{id}
</update>
<update id="updateUserPwd" parameterType="map">
update T_USER set password=#{password} where id = #{id}
</update>

<delete id="deleteUserById">
delete from T_USER where id = #{id}
</delete>
</mapper>


各位大虾帮看下哪里有问题。
...全文

相关推荐

mybatisMapped报错 Statements collection does not contain value for

mytabis 报错 Mapped Statements collection does not contain value for

wangdujing

mybatisMapped error Statements collection does not contain value for

代码下载链接: https://pan.quark.cn/s/145786a52cde ### mybatis映射报错:映射语句集合中不存在指定ID的语句在使用MyBatis框架执行数据库操作时,用户可能会接收到“Mapped Statements collection does not contain value for”类型的错误信息。该错误通常表明MyBatis在执行过程中无法定位到与所指定ID相匹配的映射语句。接下来将深入探讨该问题的成因、可能引发的影响以及相应的解决策略。#### 错误成因剖析1. **Mapper配置文件未能正确加载**: - 在项目配置环节,MyBatis可能未能准确扫描到相关的Mapper配置文件。 - 配置文件中指定的资源路径存在偏差。 - Mapper文件的位置或命名未能遵循既定规范。2. **Mapper接口与XML文件关联不正确**: - Mapper接口中的方法名称与XML文件内定义的ID存在差异。 - XML文件中所声明的方法ID存在拼写错误。3. **Mapper接口未能适当注册**: - 若采用Spring框架,需确保Mapper接口被正确扫描并注册为Bean。 - 配置类中的`@MapperScan`注解使用存在不当。4. **Mapper配置文件存在语法问题**: - XML文件内的SQL语句存在错误,导致解析过程失败。 - 使用了MyBatis不支持的SQL语法或组件。5. **命名空间配置错误**: - Mapper配置文件的命名空间设置存在偏差或未进行设置。 - 命名空间与Mapper接口所在的包路径不吻合。#### 解决方案指导1. **核查配置文件**: - 确认MyBatis配置文件(例如`myba...

dns_boom

CRM在通用.doc

上海通用是上海汽车工业(集团)总公司和美国通用汽车公司各投资50%组建而成的迄今为止我国最大的中美合资企业,总投资为15.2亿美元。共有冲压、车身、油漆、总装和动力总成五大车间。严格按照精益生产原则规划、设计、建设和管理工厂,五大车间采用模块化设计、柔性化生产,可以实现多个车型共线生产,以便满足汽车市场客户需求多元化的选择。

killer0717

Collections

苹果collection的文档,官方的

xinlingdedahai

Delphi7.1 Update

Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main productdocumentation, and supersedes information contained in otherdocuments, including previously installed release notes.Borland recommends that you read this file in its entirety.NOTE: If you are updating a localized version of Delphi 7, visit the Borland Registered User web site to obtain a localized readme file that may contain important late- breaking information not included in this readme file.IMPORTANT: Delphi must be closed before installing this update. =====================================================CONTENTS * INSTALLING THIS UPDATE * UPDATING LOCALIZED VERSIONS OF DELPHI 7 * KNOWN ISSUES * ISSUES ADDRESSED BY THIS UPDATE - IDE - CORE DATABASE - DATASNAP - DBGO (ADO COMPONENTS) - dbExpress - dbExpress COMPONENTS AND DB VCL - dbExpress CORE DRIVER AND METADATA - dbExpress VENDOR ISSUES - dbExpress CERTIFICATION - WEB SNAP - ACTIVEX - COMPILER - RTL - VCL - THIRD PARTY - BOLD FOR DELPHI * VERIFYING THAT THE UPDATE WAS SUCCESSFUL * FILES INSTALLED BY THIS UPDATE =======================================================INSTALLING THIS UPDATE* This update can not be applied to Delphi 7 Architect Trial version. * This update can not be removed after it is installed.* You will need the original Delphi 7 installation CD available to install this update.* To install this update from the CD, insert the CD, and launch the d7_ent_upd1.exe file appropriate for your locale.* To install this update from the Web, double-click the self-executing installation file and follow the prompts. * The Delphi 7 documentation PDF files are available on the update CD.========================================================UPDATING LOCALIZED VERSIONS OF DELPHI 7* This update can be applied only to the English version of Delphi 7. There are separate updates for the German, French and Japanese ver

chenxh
评论 5
收藏 已收藏
分享
返回顶部
matrix1984
Java EE 67,535 成员 225,843 内容