以下是我的代码文件:
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;
import java.util.List;
/**
* HourlyElectricity Repository is for all operations for HourlyElectricity.
* @author Crossover
*/
@RestResource(exported = false)
public interface DailyElectricityRepository
extends JpaRepository<HourlyElectricityRepository,Long> {
@Query(value="SELECT reading_at,sum(generated_electricity),avg(generated_electricity),min(generated_electricity),max(generated_electricity)" +
"FROM hourly_electricity WHERE " +
"panel_id=:panelId ", nativeQuery=true)
List<DailyElectricity> allDailyElectricityFromYesterday( @Param("panelId")Long panelId);
}
添加此文件时发现以下错误 2018-06-14 21:10:35.554 ERROR 17596 --- [restartedMain] o.s.boot.SpringApplication:应用程序运行失败
org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为&#39; panelController的bean时出错:通过字段“dailyElectricityRepository”表示不满意的依赖关系&#39;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为&#39; dailyElectricityRepository&#39;的init时出错:init方法的调用失败;嵌套异常是java.lang.IllegalArgumentException:不是托管类型:interface com.crossover.techtrial.repository.HourlyElectricityRepository 在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587)〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1348)〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578)〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在org.springfra