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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

ServiceImpl 中構(gòu)造函數(shù)的參數(shù) 0 需要一個(gè) DAO 類型的 bean,但無法找到

ServiceImpl 中構(gòu)造函數(shù)的參數(shù) 0 需要一個(gè) DAO 類型的 bean,但無法找到

撒科打諢 2023-07-19 15:53:56
在創(chuàng)建使用 Hibernate 作為 ORM 將對(duì)象保存在數(shù)據(jù)庫中的服務(wù)時(shí),我無法啟動(dòng)該應(yīng)用程序。我正在使用 Spring Boot 和 Hibernate。我的服務(wù)實(shí)現(xiàn):@Servicepublic class PropertyServiceImpl implements PropertyService{private PropertyDAO propertyDAO;    public PropertyServiceImpl(){    System.out.println("inside propertyserviceimpl constructor");}@Autowiredpublic PropertyServiceImpl(PropertyDAO propertyDAO){    this.propertyDAO = propertyDAO;    System.out.println("inside save");}@Transactionalpublic void save(Property property) {    propertyDAO.save(property);}@Overridepublic List findAll() {    // TODO Auto-generated method stub    return null;}}PropertyDAO.javapublic interface PropertyDAO {public void save(Property property); }PropertyDAOImpl 實(shí)現(xiàn) DAOpublic class PropertyDAOImpl implements PropertyDAO{@Autowiredprivate SessionFactory sessionFactory;public void save(Property property) {    Session currentSession = sessionFactory.getCurrentSession();    currentSession.saveOrUpdate(property);}}當(dāng)我啟動(dòng) SpringBoot 應(yīng)用程序時(shí),收到以下錯(cuò)誤消息。***************************APPLICATION FAILED TO START***************************Description:Parameter 0 of constructor in com.flarow.flarowhomes.services.PropertyServiceImpl required a bean of type 'com.flarow.flarowhomes.dao.PropertyDAO' that could not be found.Action:Consider defining a bean of type 'com.flarow.flarowhomes.dao.PropertyDAO' in your configuration.
查看完整描述

2 回答

?
千巷貓影

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

將@Repository添加到您的 DAO 實(shí)現(xiàn)類中,以便可以找到它:

@Repository
public?class?PropertyDAOImpl?implements?PropertyDAO?{

實(shí)現(xiàn)傳統(tǒng) Java EE 模式(例如“數(shù)據(jù)訪問對(duì)象”)的團(tuán)隊(duì)也可以將此構(gòu)造型應(yīng)用于 DAO 類,但在此之前應(yīng)注意了解數(shù)據(jù)訪問對(duì)象和 DDD 樣式存儲(chǔ)庫之間的區(qū)別。


查看完整回答
反對(duì) 回復(fù) 2023-07-19
?
慕少森

TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊

按如下方式更改您的 PropertyDAO:

public interface PropertyDAO extends JpaRepository<Property, Integer>{ }


查看完整回答
反對(duì) 回復(fù) 2023-07-19
  • 2 回答
  • 0 關(guān)注
  • 263 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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