尝试启动应用程序时出现以下错误。 我尝试了多溶液解决方案,但似乎没有任何作用。
*原因: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)创建查询!找不到类型为Test的属性findResultByCodeAndProfile!
....... ................
.............省略了47个共同的框架 原因:org.springframework.data.mapping.PropertyReferenceException:未找到类型Test的属性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");
//
//
}
-TestRepository接口
public interface TestRepository extends BaseRepository<Test, Long>, TestRepositoryCustom {
{
@Query(TestQueries.NOTE_QRY)
Page<TestDto> getHistory(@Param("Key") String Key,
@Param("Value") String Value);
}
-BaseRepository接口。
@NoRepositoryBean
public interface BaseRepository <T, ID extends Serializable> extends JpaRepository<T, ID>, QueryByExampleExecutor<T>{
}
-TestRespositoryCustom
public interface TestRespositoryCustom
{
public List<TestDto> findResultByCodeAndProfile(String testObjKey, String testObjValue);
}
-TestRespositoryImpl
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();
}
-BaseRepositoryCustom
public class BaseRepositoryCustom {
@Value("${spring.jpa.properties.hibernate.default_schema}")
public String defaultSchema;
@PersistenceContext
protected EntityManager entityManager;
}