当前位置: 首页 > 知识库问答 >
问题:

无法为公共抽象 java.util.list 创建查询

王弘和
2023-03-14

代码--

错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'resumeManager' defined in file [C:\Users\furkan\IdeaProjects\Resume\target\classes\com\example\resume\Business\concretes\ResumeManager.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resumeDao' defined in com.example.resume.DataAcces.ResumeDao defined in @EnableJpaRepositories declared on ResumeApplication: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()! Reason: Validation failed for query for method public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()!
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1354) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.1.jar:2.5.1]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.1.jar:2.5.1]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.1.jar:2.5.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.1.jar:2.5.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.1.jar:2.5.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.1.jar:2.5.1]
    at com.example.resume.ResumeApplication.main(ResumeApplication.java:18) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resumeDao' defined in com.example.resume.DataAcces.ResumeDao defined in @EnableJpaRepositories declared on ResumeApplication: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()! Reason: Validation failed for query for method public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()!
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.8.jar:5.3.8]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.8.jar:5.3.8]
    ... 19 common frames omitted
Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()! Reason: Validation failed for query for method public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.example.resume.DataAcces.ResumeDao.getResumeDto()!
    at 

共有1个答案

韦胜泫
2023-03-14

DTO名称应该是完全限定的,并且应该在查询中提供Entity类以使用Hibernate连接表。

 @Query("select new com.example.resume.Entity.Dto.ResumeDto (a.experienceName, e.schoolName,e.firstYear, e.endYear, a.experienceDescription) " +
            "from Resume j ,Education e , Experience a where j.experience.id=a.id and j.education.id=e.id")
 List<ResumeDto> getResumeDto();
 类似资料:
  • 在与图书馆版本作斗争之后,我已经到了一个进退两难的地步。类似的问题似乎不适用,因为它已经三年了,我正在使用更新版本的东西,而且它抱怨

  • 堆栈跟踪:组织。springframework。豆。工厂UnsatisfiedDependencyException:创建名为“userController”的bean时出错:通过字段“userRepository”表示的未满足的依赖关系;嵌套异常为org。springframework。豆。工厂BeanCreationException:创建br中定义的名为“userRepository”的be

  • 嗨,我有一个抽象类,其中有一些公共方法和一些抽象方法。我让公众知道,他们实现了派生类的通用方法。 让我困惑的是,为什么我想定义一个公共抽象方法,而不是受保护的抽象方法。在抽象类中定义公共抽象方法对我来说毫无意义。。。。因为if是一个抽象,在派生类中会被重写,但if被定义为public也是一样的,但在某种程度上,将其定义为protected更有意义,因为我们知道,我们将在派生类中重写它。 在抽象类中

  • 我最近遇到了以下方法。我试着用谷歌搜索,并通过定义如下方法,做了一个例子来了解差异;两者似乎是一样的。但是,我需要知道它是否真的是一样的? 注意:在以上两种方法中,公共代码和抽象代码已经互换。

  • 这是因为这行代码: 所以我试着用这行代码看看它是什么类型: 但是我得到了同样的错误,所以它不让我知道它是什么类型。下面你可以看到我的代码。

  • 我正在开发SpringMVC+Spring-data-jpa+querydsl,我是新手。当我为querydsl编写代码时(在该代码正常工作之前),当我添加与querydsl相关的代码时,我开始出现以下错误,不确定哪里出了问题。请引导。 供参考的错误: visit.java