Consider defining a bean of type ‘com.example.mall.mapper.UserMapper‘ in you

我们在springboot整合mybatis时,有时会出现这个错误:Consider defining a bean of type ‘com.example.mall.mapper.UserMapper’ in you,意思是说,在你的项目中找不到"UserMapper"这个类。

        解决方法:

        方式一:在Mapper接口上加注解@Mapper

@Mapper  //表示这是一个mybatis的mapper类,也就是dao
@Component
public interface UserMapper {
    User admin(@Param("userName") String name,@Param("userPassword") String pwd);
}


        方式二:在启动类上加上@MapperScan这个注解

@SpringBootApplication
@MapperScan({"app.mapper","app.test01.dao","app.test02.dao"})
public class MallApplication {

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

}


        总结:

        @SpringBootApplicatoin注解是由@Configuration和@EnableAutoConfiguration和@ComponentScan组成的。
        @SpringBootApplicatoin是用的@ComponentScan扫描的,扫描的是Component,包括@Component, @Controller, @Service, @Repository等。
        在对Mybatis自动扫描配置中,使用注解配置时,我们只要在@MapperScan中配置我们需要扫描的Mapper位置,大部分情况下是满足需求的。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
What is dip? dip is an application development and integration framework for Python and PyQt. dip supports Python v3.x, v2.6 and v2.7. dip is suitable for writing large, complex applications, even those that need to integrate substantial amounts of existing code without changing that code. It is also just as suitable for writing simple GUI utilities. Like any framework dip aims to make common tasks easy and uncommon tasks possible. dip encourages the development of applications based on reusable components. This applies both to the development of new components so that they can be reused in the future in a different context, and to the reuse of existing components that were developed independently of dip. Developers can choose to use the different parts of dip as required. dip does not require the wholesale adoption of the framework to develop an application. Developers can also choose to replace different parts of dip with their own implementations. dip's documentation can be found here. It includes tutorials on using the various dip modules and a complete API reference. Features dip includes the following features: the dip-builder utility that can be used to create a stub application that can be run immediately, and can create a packaged version of the application for easy deployment a plugin system that encourages the decoupling, and easy reuse, of components through the use of services and extension points a declarative type system where class attributes define the types of instance attributes that are created automatically when the class is instantiated the ability to define interfaces and to write adaptors that allow an object to appear to implement an interface without needing to change the object itself the ability to specify a user interface declaratively. When combined with the type system it is possible to create a user interface that allows the user to edit a data model with a single line of code dip's user interfaces are testable because a user's actions can be simulated programatically a framework for defining types of storage and data formats for reading and writing application objects a default user interface shell, based on QMainWindow that implements the menu hierarchies, context menus, toolbars etc. common to many applications support for alternative, Qt-based toolkits. For example, an application can automatically use KDE widgets rather than the corresponding Qt widgets if they are available.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值