第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在springboot中自動裝配時無法找到某種類型的bean

在springboot中自動裝配時無法找到某種類型的bean

三國紛爭 2021-05-31 22:30:02
在我開始之前,請假設(shè)它pom.xml是完美無缺的。話雖如此,讓我們繼續(xù),我得到的錯誤如下:應(yīng)用程序無法啟動 *************************** 說明:com.sagarp.employee.EmployeeService 中的字段 empDao需要一個無法找到的類型為“com.sagarp.employee.EmployeeDao”的 bean?,F(xiàn)在spring boot application類如下:package com.sagarp;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.EnableEurekaClient;import org.springframework.context.annotation.ComponentScan;@SpringBootApplication@EnableEurekaClient //this is for eureka which not our concern right now.@ComponentScan(basePackages = "com.sagarp.*") //Included all packagespublic class EmployeeHibernateApplication {    public static void main(String[] args) {        SpringApplication.run(EmployeeHibernateApplication.class, args);    }}該EmployeeService班是如下:package com.sagarp.employee;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;@Servicepublic class EmployeeService {    @Autowired    private EmployeeDao empDao; // interface    public EmployeeDao getEmpDao() {        return empDao;    }    public void setEmpDao(EmployeeDao empDao) {        this.empDao = empDao;    }    //some methods}請注意,這EmployeeDao是一個接口。EmployeeDao 界面如下:public interface EmployeeDao {    //Oh! so many methods to I have provided}EmployeeDaoImpl實現(xiàn)EmployeeDao接口的類。public class EmployeeDaoImpl implements EmployeeDao {    @Autowired    private SessionFactory sessionFactory;    //Oh!So many methods I had to implement}我猜EmployeeService是因為@Service它是自動裝配的。我添加了所有包,components以便它掃描并實例化我可能擁有的所有依賴項。但它沒有,因此問題。任何人都可以幫助我解決上述詳細信息的錯誤。如果需要更多詳細信息,請告訴我。
查看完整描述

3 回答

?
MMTTMM

TA貢獻1869條經(jīng)驗 獲得超4個贊

組件掃描搜索使用 Spring Stereotype 注釋注釋的類。為了使類有資格進行自動裝配,它必須具有這些注釋之一。

解決方案是使用@Component、@Service 或@Repository 注釋EmployeeDaoImpl。


查看完整回答
反對 回復(fù) 2021-06-02
  • 3 回答
  • 0 關(guān)注
  • 4759 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號