Java-春季启动-无法自动接线-找不到bean

时间:2018-12-03 10:09:17

标签: java spring spring-boot

我有一个Data Loader类,该类应该在应用启动后加载数据。 我的错误-

无法自动接线。找不到“ OwnerService”的bean。

但是,如下所示,为我的ownerService类添加了注释-

这是应该这样做的课程-

DataLoader

    import model.Owner;
import model.Vet;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import services.OwnerService;
import services.VetService;
import services.map.OwnerServiceMap;
import services.map.VetServiceMap;

@Component
public class DataLoader implements CommandLineRunner {

    private final OwnerService ownerService;
    private final VetService vetService;



    public DataLoader(OwnerService ownerService, VetService vetService) {
        this.ownerService = ownerService;
        this.vetService = vetService;
    }

OwnerServiceMap

    package services.map;


import model.Owner;
import org.springframework.stereotype.Service;
import services.OwnerService;

import java.util.Set;

@Service
public class OwnerServiceMap extends AbstractMapService<Owner,Long> implements OwnerService 

{//some code here}

vetService与ownerService相同。

我的应用课程-

package petclinic;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class PetclinicApplication {

    public static void main(String[] args) {

        SpringApplication.run(PetclinicApplication.class, args);
    }
}

也许我有层次结构问题,因为应用程序类没有在项目中足够的位置搜索bean?

project

谢谢!

0 个答案:

没有答案