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
//开始导致其他程序包出现相同的错误答案 0 :(得分:1)
这可能是由于错误的映射引起的,在查询中有where page_id=?1
,而参数的名称是pageID
。那些应该相等。错误的映射导致没有bean注入。