繁体   English   中英

Spring Boot项目错误创建bean

[英]Spring Boot project error creating bean

我有以下代码:

package com.frameworkonly.webapp;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.frameworkonly.webapp.domain.Employee;
import com.frameworkonly.webapp.service.EmployeeServiceInterface;

@EnableAutoConfiguration(exclude = {ErrorMvcAutoConfiguration.class})
@ComponentScan("com.frameworkonly.webapp")
public class SpringBootDemoApplication {

    @Autowired
    EmployeeServiceInterface employeeServiceInterface;

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

我刚开始使用Spring Boot 它给了我以下信息,我不知道这意味着什么:

Error creating bean with name 'springBootDemoApplication': Injection of 
autowired dependencies failed; nested exception is 
org.springframework.beans.factory.BeanCreationException: Could not autowire 
field: com.exemple.service.PatientServiceInterface 
com.example.SpringBootDemoApplication.patientServiceInterface; nested 
exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type [com.exemple.service.PatientServiceInterface] 
found for dependency: expected at least 1 bean which qualifies as autowire 
candidate for this dependency. 

添加com.exemple.service到扫描包假设列表PatientServiceInterface都被注解@Service

@ComponentScan({"com.frameworkonly.webapp","com.exemple.service"})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM