簡體   English   中英

com.abc.serive.MysqlService 中的字段 countRepo 需要一個無法找到的“com.abc.repository.ClicksQuickReplyRepository”類型的 bean

[英]Field countRepo in com.abc.serive.MysqlService required a bean of type 'com.abc.repository.ClicksQuickReplyRepository' that could not be found

package com.abc.repository.ClicksQuickReplyRepository;

import com.abc.model.ClicksQuickReply;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;

@Repository
public interface ClicksQuickReplyRepository{

    @Query( value = "select notificationTag,count,button_id from fb_sent_messages where page_id=?1 and notificationTag in ?2", nativeQuery=true)
    List<ClicksQuickReply> getClickCount(@Param("pageID") String pageID, @Param("notificationTag")  String notificationTag);
}

MySQL服務類

package com.abc.serive.MysqlService;

@Service
public class MysqlService {

@Autowired
    private ClicksQuickReplyRepository clicksQuickReplyRepository;

} 

自動裝配 ClicksQuickReplyRepository 會導致錯誤:

Field clicksQuickReplyRepository in com.abc.serive.MysqlService required a bean of type 'com.abc.repository.ClicksQuickReplyRepository' that could not be found.

我嘗試了以下嘗試修復它:

  1. @EnableJpaRepositories添加到 SpringConfiguration 類
  2. 添加@SpringBootApplication(scanBasePackages={"com.abc.repository"})scanBasePackage // 開始導致其他包出現同樣的錯誤

這可能是由錯誤的映射引起的,在您的查詢中有where page_id=?1而您的參數名稱是pageID 這些應該是平等的。 錯誤的映射導致沒有 bean 注入。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM