Java Spring JPArepository验证与查询方法
我在ClientRespository中实现此方法时遇到问题:Java Spring JPArepository验证与查询方法,java,spring,spring-boot,Java,Spring,Spring Boot,我在ClientRespository中实现此方法时遇到问题: public interface ClientRepository extends JpaRepository<Client,Long> { @Query("select n from Client where n.nom like :x") public Page<Client> chercher(@Param("x") String mc , Pageable pageable); }
public interface ClientRepository extends JpaRepository<Client,Long> {
@Query("select n from Client where n.nom like :x")
public Page<Client> chercher(@Param("x") String mc , Pageable pageable);
}
例外情况:
启动ApplicationContext时出错。要显示条件报告,请在启用“调试”的情况下重新运行应用程序。
2018-05-23 10:33:32.606错误15048-[restartedMain]o.s.boot.SpringApplication:应用程序运行失败
org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“maBanqueApplication”的bean时出错:通过字段“clientRepository”表示未满足的依赖关系;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“ClientRespository”的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:查询方法public abstract org.springframework.data.domain.Page org.sid.Dao.clientpository.chercherClientjava.lang.String,org.springframework.data.domain.Pageable时验证失败!
位于org.springframework.beans.factory.annotation.AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement.InjectAutoWiredNotationBeanPostProcessor.java:587~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
在org.springframework.beans.factory.annotation.InjectionMetadata.InjectionMetadata.java:91~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
您的查询是错误的:
@Query("select n from Client where n.nom like :x") // You select `n` from no where
换成
@Query("select n from Client n where n.nom like :x")
您的查询是错误的:
@Query("select n from Client where n.nom like :x") // You select `n` from no where
换成
@Query("select n from Client n where n.nom like :x")