Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot BeanCreationException:创建名为';重置';:调用init方法失败_Spring Boot_Jpa_Spring Data Jpa_Beancreationexception - Fatal编程技术网

Spring boot BeanCreationException:创建名为';重置';:调用init方法失败

Spring boot BeanCreationException:创建名为';重置';:调用init方法失败,spring-boot,jpa,spring-data-jpa,beancreationexception,Spring Boot,Jpa,Spring Data Jpa,Beancreationexception,我在尝试启动应用程序时遇到以下错误。 我试过几种解决办法,但似乎都不管用 *原因:org.springframework.beans.factory.BeanCreationException:创建名为“testRepository”的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:未能为方法public abstract java.util.List com.test.base.repository.TestResposit

我在尝试启动应用程序时遇到以下错误。 我试过几种解决办法,但似乎都不管用

*原因:org.springframework.beans.factory.BeanCreationException:创建名为“testRepository”的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:未能为方法public abstract java.util.List com.test.base.repository.TestRespositoryCustom.findResultByCodeAndProfile(java.lang.String,java.lang.String)创建查询!找不到用于类型测试的findResultByCodeAndProfile属性

。。。。。。。。。。。。。。。。

。。。。。。。。。。。。省略47个公共框架 原因:org.springframework.data.mapping.PropertyReferenceException:找不到用于类型测试的属性findResultByCodeAndProfile! 在org.springframework.data.mapping.PropertyPath.(PropertyPath.java:94)~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE] 在org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382)~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]*

我的服务类正在调用findResultByCodeAndProfile方法,该方法调用接口TestRespositoryCustom,其实现是 TestRespositoryImpl类中有以下内容

“Test.java是实体类”

--服务舱

@Autowired
TestRepository testRepository;

     public void getHotelProfileLatestTest(String hotelCode)
    {
        List<TestDto> testList = testRepository.findResultByCodeAndProfile(secondaryCode, "profile");
        //
        //
    }

你发布的代码无法编译。您的实现重写了一个不存在的findAll()方法,并且没有重写接口中声明的findResultByCodeAndProfile方法。这是从eclipse复制粘贴到此处的错误。。我的不好,我更正了它。类名应该是TestRespositoryCustomImpl(即,接口名后跟Impl),请参阅
public interface TestRepository extends BaseRepository<Test, Long>, TestRepositoryCustom {

    {
    @Query(TestQueries.NOTE_QRY)
    Page<TestDto> getHistory(@Param("Key") String Key,
            @Param("Value") String Value);
    }
        @NoRepositoryBean
    public interface BaseRepository <T, ID extends Serializable> extends JpaRepository<T, ID>, QueryByExampleExecutor<T>{

}
public interface TestRespositoryCustom
{
    public List<TestDto> findResultByCodeAndProfile(String testObjKey, String testObjValue);
}
public class TestRespositoryImpl extends BaseRepositoryCustom implements TestRespositoryCustom
{
   @Override
    public List<TestDto> findResultByCodeAndProfile(String testObjKey, String testObjValue)
    {
        String sql = TC_NOTE_QRY;
        Query query = entityManager.createQuery(sql);
        query.setMaxResults(3);
        query.setParameter("testObjKey", testObjKey);
        query.setParameter("testObjValue", testObjValue);
        return (List) query.getResultList();
    }
public class BaseRepositoryCustom {

    @Value("${spring.jpa.properties.hibernate.default_schema}")
    public String defaultSchema;

    @PersistenceContext
    protected EntityManager entityManager;

}