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>


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

相关推荐

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