Giter Site home page Giter Site logo

Comments (7)

abel533 avatar abel533 commented on June 26, 2024

应该是你写错了。有可能属于下面的某种情况:

AMapper<A> extends Mapper<A>

或者

AMapper extends Mapper

正确的应该是

AMapper extends Mapper<A>

from mybatis-spring-boot.

helloworldtang avatar helloworldtang commented on June 26, 2024

刚才把代码搜了一遍,写法和上面说的一致。

我这边的场景是这样的:

这种写法就不报错
package com.sns.schedule;
@SpringBootApplication(scanBasePackages = {"com.sns"})
public class Application{

这样写就报上面的错(之所以这么折腾老代码,是觉得下面的写法优雅):
package com.sns;
@SpringBootApplication
public class Application{

from mybatis-spring-boot.

abel533 avatar abel533 commented on June 26, 2024

还有一种可能就是你扫描到基类接口了。这类接口没有指定泛型,不能被扫描。

from mybatis-spring-boot.

helloworldtang avatar helloworldtang commented on June 26, 2024

老代码比较早,当时还没有通用mapper的autoconfig,

通用mapper的的MyMapper.java在“com.sns.data”下,
业务Mapper是使用“tk.mybatis.spring.mapper.MapperScannerConfigurer”来自动配置,

你看看有没有上面写的问题,具体代码如下:
mapperscanner

from mybatis-spring-boot.

abel533 avatar abel533 commented on June 26, 2024

你用 mybatis-starter 了吗?也有可能是自动配置扫描到了接口。

from mybatis-spring-boot.

helloworldtang avatar helloworldtang commented on June 26, 2024

这个有。代码写的比较乱,把能用或不能用的dependencies都放到Pom文件中了。
但是在代码中显式声明了tk.mybatis.spring.mapper.MapperScannerConfigurer,按照starter这种自动配置的逻辑,如果有MapperScannerConfigurer的实例了,就不会再重复初始化实例了
这样看的话,应该也没有什么影响吧

from mybatis-spring-boot.

JohnNiang avatar JohnNiang commented on June 26, 2024

这里有一个问题,如果自定义的Mapper接口在AMapper所在包的下面或者子包下面也会报这样的错误。
@abel533

from mybatis-spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.