![](/img/trans.png)
[英]Field abc in com.aaa.controller.AbcController required a bean of type 'com.aaa.repository.AbcRepository' that could not be found
[英]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.
我嘗試了以下嘗試修復它:
@EnableJpaRepositories
添加到 SpringConfiguration 類@SpringBootApplication(scanBasePackages={"com.abc.repository"})
即scanBasePackage
// 開始導致其他包出現同樣的錯誤這可能是由錯誤的映射引起的,在您的查詢中有where page_id=?1
而您的參數名稱是pageID
。 這些應該是平等的。 錯誤的映射導致沒有 bean 注入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.