java.lang.NoSuchMethodException: .mapper.DianMapper.<init>()

1.检查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="org.zjh.openlayersdemo.mapper.DianMapper">

// 注意下面type后为对应实体类全路径
    <resultMap id="dianResultMap" type="org.zjh.openlayersdemo.entity.Dian" >
        <id column="id" property="id" jdbcType="SMALLINT" />
        <result column="d_num" property="dNum" jdbcType="SMALLINT" />
        <result column="d_type" property="dType" jdbcType="VARCHAR" />
        <result column="d_address" property="dAddress" jdbcType="VARCHAR"/>
        <result column="d_shape" property="dShape" jdbcType="VARCHAR" />
        <result column="d_name" property="dName" jdbcType="VARCHAR"/>
        <result column="d_address" property="dAddress" jdbcType="VARCHAR"/>
    </resultMap>

// 注意返回结果resultType为对象还是List,id是否与mapper接口中的方法名一致
    <select id="selectAllById" resultType="org.zjh.openlayersdemo.entity.Dian">
        select * from dian where id=#{id}
    </select>

</mapper>

2.检查mapper接口


package org.zjh.openlayersdemo.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.zjh.openlayersdemo.entity.Dian;

import java.util.List;

@Mapper
public interface DianMapper {

// 注意方法名与xml中增删改查的id相对应
    Dian selectAllById(Integer id);

}

3.检查application启动类

package org.zjh.openlayersdemo;


import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

// 检查下面路径是否为xml文件路径
@MapperScan("org.zjh.openlayersdemo.mapper")
public class OpenlayersdemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(OpenlayersdemoApplication.class, args);
    }

}

4.检查application.yml配置文件

mybatis:

 # 注意下面的路径
  mapper-locations: classpath:mybatis/mapper/*Mapper.xml
  type-aliases-package: org.zjh.openlayersdemo.entity
  configuration:
    # 驼峰命名
    map-underscore-to-camel-case: true
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值