mybatis:ssource is null for getProperty(null, “roleId“)报错

pom.xml加入pagehelper插件依赖

<!--分页插件pagehelper-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>5.1.11</version>
        </dependency>

application.yml加入pagehelper插件配置

#页插件配置:pagehelper分页
pagehelper:
  helperDialect: mysql
  offsetAsPageNum: true
  rowBoundsWithCount: true
  reasonable: false
  supportMethodsArguments: true
  returnPageInfo: true
  params: count=countSql

UserMapper.xml错误

<!--分页查询-->
  <select id="selectPage"   parameterType="com.example.springboot.entity.User"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user
    <where>
      <if test="user !=null">
          <if test="user.username != null and user.username.trim().length()>0">
              <bind name="usernamePattern" value="'%' + user.username + '%'"/>
              AND username like #{usernamePattern}
          </if>
          <if test="user.nickname != null and user.nickname.trim().length()>0">
              <bind name="nicknamePattern" value="'%' + user.nickname + '%'"/>
              AND nickname like #{nicknamePattern}
          </if>
          <if test="user.roleId != null and user.roleId != ''">
              AND role_id=#{user.roleId}
          </if>
          <if test="user.id != null and user.id != '' ">
              AND id=#{user.id}
          </if>
      </if>

      </where>

UserMapper.xml正确

<!--分页查询-->
  <select id="selectPage"   parameterType="com.example.springboot.entity.User"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user
    <where>
          <if test="user.username != null and user.username.trim().length()>0">
              <bind name="usernamePattern" value="'%' + user.username + '%'"/>
              AND username like #{usernamePattern}
          </if>
          <if test="user.nickname != null and user.nickname.trim().length()>0">
              <bind name="nicknamePattern" value="'%' + user.nickname + '%'"/>
              AND nickname like #{nicknamePattern}
          </if>
          <if test="user.roleId != null and user.roleId != ''">
              AND role_id=#{user.roleId}
          </if>
          <if test="user.id != null and user.id != '' ">
              AND id=#{user.id}
          </if>
      </where>

userMapper.java

  /*分页查询全部*/
    Page<User> selectPage(@Param("user") User user,
                          @Param("pageNum") int pageNum,
                          @Param("pageSize") int pageSize);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值