猿问

通过字段“dashboardService”表达的不满意的依赖;

我知道这个问题已经被问过很多次了,但我真的很难找到正确的解决方案。通过看到这些问题,我尝试了很多东西,但似乎没有一个适合我的情况。

这是我目前的实现:


SpringBoot应用程序:


@SpringBootApplication

@EnableJpaRepositories(basePackages="com.timmi.springBoot.repositories")

@EntityScan(basePackages="com.timmi.springBoot.entities")

@EnableAutoConfiguration

@ComponentScan(basePackages="com.timmi.springBoot.service")

public class Application extends SpringBootServletInitializer {


    public static void main(String[] args) {

            SpringApplication.run(Application.class, args);

    }


    @Override

    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

        // TODO Auto-generated method stub

        return super.configure(builder);

    }

}

休息控制器:


@RestController

@RequestMapping("/app")

public class RestEndPoints {


    @Value("${default.course.name}")

    private String cName;


    @Value("${default.course.chapterCount}")

    private int chaptersCount;


    @Autowired

    private CourseConfiguration courseConfiguration;


    @Autowired

    private DashboardService dashboardService;


    @RequestMapping("/employees")

    public List<EmployeeInformation> getAllEmpl(){


        return dashboardService.getAllEmployee();


    }

}

仪表板服务接口:


public interface DashboardService{


    List<CompanyRevenue> getTodayRevenueDash();


    List<ProductCategory> getBestCategory();


    List<OrderRecieved> getAllOrderRecieved();


    List<OrderCollectionStatus> getOrderCollection();


    List<EmployeeInformation> getAllEmployee();


    void addEmployee(EmployeeInformation employeeInformation);


    EmployeeInformation updateEmployee(EmployeeInformation employeeInformation);


    void deleteEmployee(EmployeeInformation employeeInformation);


}


ibeautiful
浏览 189回答 2
2回答

冉冉说

所以解决的办法是把应用类放在root包里,所以这里不需要做ComponantScan注解

倚天杖

删除@Repository并@Qualifier从您DashboardService和@Component来自DashboardServiceImpl
随时随地看视频慕课网APP

相关分类

Java
我要回答