JAVA入门大坑:expected at least 1 bean which qualifies as autowire candidate. Dependency annotations

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helloWord': Unsatisfied dependency expressed through field 'testMapper': Error creating bean with name 'testMapperImpl': Unsatisfied dependency expressed through field 'testDao': No qualifying bean of type 'com.example.myspringboot.Dao.TestDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Description:

Field testDao in com.example.myspringboot.Service.TestMapperImpl required a bean of type 'com.example.myspringboot.Dao.TestDao' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.example.myspringboot.Dao.TestDao' in your configuration.

不要用这个注释:

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

只用:

@SpringBootApplication

//@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
//@MapperScan()
@SpringBootApplication
//@EnableScheduling
public class MySpringBootApplication {
    public static void main(String[] args) {
        SpringApplication.run(MySpringBootApplication.class, args);
    }
}

dao层无法注入service

你可能感兴趣的:(java,mysql,mybitas,java,jvm,开发语言,mysql)