zoukankan      html  css  js  c++  java
  • Description: Field ud in com.yjj.service.impl.UserServiceImpl required a bean of type 'com.yjj.dao.UserDao' that could not be found. Action: Consider defining a bean of type 'com.yjj.dao.UserDao'

    这是在用springboot时遇到的error

    Description:

    Field ud in com.yjj.service.impl.UserServiceImpl required a bean of type 'com.yjj.dao.UserDao' that could not be found.

    Action:

    Consider defining a bean of type 'com.yjj.dao.UserDao' in your configuration.

    原因:

    我找到的一种原因是在mappers文件夹下的mapper.xml文件没有扫到com.yjj.dao这个包

    所以要在Application(启动类)上加上

    @MapperScan("com.yjj.dao")注解

    代码如下:
    package com.yjj.bootdemo01;
    
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.ComponentScan;
    
    @SpringBootApplication
    @ComponentScan(basePackages = {"com.yjj.dao","com.yjj.service","com.yjj.controller"})
    @MapperScan("com.yjj.dao")
    public class Bootdemo01Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Bootdemo01Application.class, args);
        }
    
    }
    
    
  • 相关阅读:
    Centos/Docker/Nginx/Node/Jenkins 操作
    MyBatis 流式查询
    127.0.0.1
    Spring中的@Bean注解
    工厂模式
    webservice
    vs每次拉下一个控件都必选设置为绝对位置才可以移动,怎样解决啊
    ASP.NET AJAX 概述
    AJAX介绍
    时间控件
  • 原文地址:https://www.cnblogs.com/leafarmyarmy/p/10564509.html
Copyright © 2011-2022 走看看