简体   繁体   English

Spring Data Envers-PropertyReferenceException:找不到属性Foo类型的修订版

[英]Spring Data Envers - PropertyReferenceException: No property findRevisions found for type Foo

I do have a Sprint-Boot application and try to add hibernate-envers or to be more specific spring-data-envers to the project. 我确实有一个Sprint-Boot应用程序,并尝试hibernate-envers添加hibernate-envers或更具体的spring-data-envers

So I added 所以我加了

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-envers</artifactId>
</dependency>

The Revision entity is successfully generated/created and it was saved until I tried to user the RevisionRepository. Revision实体已成功生成/创建并保存,直到我尝试使用RevisionRepository。 Now I get errors I did not expect. 现在我得到了我没有想到的错误。

I created a new configuration like: 我创建了一个新的配置,例如:

@Configuration
@EntityScan(basePackages = {"com.package.entities"})
@EnableJpaRepositories(basePackages = "com.package.repos",
repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)
public class EnversConfiguration {}

And I extended my already working CrudRepository by: 我通过以下方式扩展了我已经在使用的CrudRepository:

@Repository
@Transactional
public interface FooRepository extends RevisionRepository<Foo, Long, Long>, CrudRepository<Foo, Long> {
    ...
}

Anytime I try to start the application it tells me: 每当我尝试启动该应用程序时,它都会告诉我:

SpringApplication.reportFailure - Application startup failed
java.lang.IllegalArgumentException: Attribute 'repositoryFactoryBeanClass' for annotation [unknown] was not resolvable due to exception [java.lang.ClassNotFoundException: org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean]
    at org.springframework.core.annotation.AnnotationAttributes.assertNotException(AnnotationAttributes.java:544)
    at org.springframework.core.annotation.AnnotationAttributes.getRequiredAttribute(AnnotationAttributes.java:429)
    at org.springframework.core.annotation.AnnotationAttributes.getClass(AnnotationAttributes.java:293)
    at org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.getRepositoryFactoryBeanName(AnnotationRepositoryConfigurationSource.java:216)
    at org.springframework.data.repository.config.DefaultRepositoryConfiguration.getRepositoryFactoryBeanName(DefaultRepositoryConfiguration.java:163)
    at org.springframework.data.repository.config.RepositoryBeanDefinitionBuilder.build(RepositoryBeanDefinitionBuilder.java:85)
    at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:125)
    at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:83)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:359)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.package.web.WebApplication.main(WebApplication.java:49)

The configuration is included like: 包括的配置如下:

@Import({ ... , EnversConfiguration.class})
public class WebApplication extends SpringBootServletInitializer implements ApplicationListener<ContextRefreshedEvent> {
   ...
}

So I found somewhere a hint that @EnableJpaRepositories(basePackages = "com.package.repos" is not needed twice, cause I got already another Configuration for the JpaRepositories, so I deleted it from EnversConfiguration 因此,我在某个地方发现了@EnableJpaRepositories(basePackages = "com.package.repos"不需要两次的提示,因为我已经为JpaRepositories获得了另一个配置,因此我从EnversConfiguration删除了它

After that I get this error: 之后,我得到这个错误:

Caused by: java.lang.NoClassDefFoundError: org/joda/time/DateTime
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethod(Class.java:2128)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.resolveMember(LocalVariableTableParameterNameDiscoverer.java:245)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.visitEnd(LocalVariableTableParameterNameDiscoverer.java:231)
    at org.springframework.asm.ClassReader.readMethod(ClassReader.java:1172)
    at org.springframework.asm.ClassReader.accept(ClassReader.java:729)
    at org.springframework.asm.ClassReader.accept(ClassReader.java:527)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer.inspectClass(LocalVariableTableParameterNameDiscoverer.java:114)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:87)
    at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:64)
    at org.springframework.data.mapping.model.PreferredConstructorDiscoverer.buildPreferredConstructor(PreferredConstructorDiscoverer.java:115)
    at org.springframework.data.mapping.model.PreferredConstructorDiscoverer.<init>(PreferredConstructorDiscoverer.java:75)
    at org.springframework.data.mapping.model.PreferredConstructorDiscoverer.<init>(PreferredConstructorDiscoverer.java:49)
    at org.springframework.data.repository.query.ReturnedType$ReturnedClass.detectConstructorParameterNames(ReturnedType.java:286)
    at org.springframework.data.repository.query.ReturnedType$ReturnedClass.<init>(ReturnedType.java:233)
    at org.springframework.data.repository.query.ReturnedType.of(ReturnedType.java:63)
    at org.springframework.data.repository.query.ResultProcessor.<init>(ResultProcessor.java:81)
    at org.springframework.data.repository.query.ResultProcessor.<init>(ResultProcessor.java:64)
    at org.springframework.data.repository.query.QueryMethod.<init>(QueryMethod.java:100)
    at org.springframework.data.jpa.repository.query.JpaQueryMethod.<init>(JpaQueryMethod.java:89)
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:449)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:222)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263)
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 133 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.joda.time.DateTime
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 162 common frames omitted

Because of some @Autowired injection of the FooRepository in a FooService: 由于在FooService中对FooRepository进行了@Autowired注入:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fooServiceImpl': Unsatisfied dependency expressed through field 'fooRepo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooRepository': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/joda/time/DateTime

Just to be sure I added the following dependency to the pom.xml and checked if packaging is set to "war" 为了确保我将以下依赖项添加到pom.xml并检查包装是否设置为“ war”

<dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
</dependency>

Update 1 (Original title: ClassNotFoundException: EnversRevisionRepositoryFactoryBean or org/joda/time/DateTime) 更新1 (原始标题:ClassNotFoundException:EnversRevisionRepositoryFactoryBean或org / joda / time / DateTime)

So I played a little bit around and changed the order of the imported configurations: 因此,我进行了一些操作,并更改了导入配置的顺序:

@Import({EnversConfiguration.class, DataAccessConfiguration.class, ...})
public class WebApplication

Afterwards I splitted FooRepository to FooRevisionRepository and FooRepository staying just a CrudRepository: 之后,我将FooRepository拆分为FooRevisionRepository,而FooRepository仅保留一个CrudRepository:

@Repository
public interface FooRevisionRepository extends RevisionRepository<Foo, Long, Integer> {}

No I get this error when starting 否,启动时出现此错误

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fooServiceImpl': Unsatisfied dependency expressed through field 'fooRevisionRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooRevisionRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query method public abstract org.springframework.data.domain.Page org.springframework.data.repository.history.RevisionRepository.findRevisions(java.io.Serializable,org.springframework.data.domain.Pageable)! No property findRevisions found for type Foo!
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
    ... 110 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooRevisionRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query method public abstract org.springframework.data.domain.Page org.springframework.data.repository.history.RevisionRepository.findRevisions(java.io.Serializable,org.springframework.data.domain.Pageable)! No property findRevisions found for type Foo!
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
    ... 123 common frames omitted
Caused by: java.lang.IllegalArgumentException: Failed to create query method public abstract org.springframework.data.domain.Page org.springframework.data.repository.history.RevisionRepository.findRevisions(java.io.Serializable,org.springframework.data.domain.Pageable)! No property findRevisions found for type Foo!
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:76)
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:101)
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:207)
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:449)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:222)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263)
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 133 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findRevisions found for type Foo!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243)
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:247)
    at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:398)
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:378)
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:86)
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:70)
    ... 143 common frames omitted

配置JPA存储库:@EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring JPA:PropertyReferenceException:找不到类型的属性findAll - Spring JPA: PropertyReferenceException: No property findAll found for type Spring 数据 Rest 错误:原因:org.springframework.data.mapping.PropertyReferenceException:找不到类型项目的属性名称 - Spring Data Rest error: Caused by: org.springframework.data.mapping.PropertyReferenceException: No property name found for type Project Spring Data自定义方法错误:org.springframework.data.mapping.PropertyReferenceException:找不到类型的属性xxx - Spring Data Custom Method Error : org.springframework.data.mapping.PropertyReferenceException: No property xxx found for type Java Spring-boot 原因:org.springframework.data.mapping.PropertyReferenceException:找不到类型的属性 ID - Java Spring-boot caused by: org.springframework.data.mapping.PropertyReferenceException: No property id found for type 没有找到类型为Event(PropertyReferenceException)的属性findEventsOnSearchCriteria - No property findEventsOnSearchCriteria found for type Event (PropertyReferenceException) org.springframework.data.mapping.PropertyReferenceException:未找到类型为User的属性更新 - org.springframework.data.mapping.PropertyReferenceException: No property update found for type User 解决org.springframework.data.mapping.PropertyReferenceException:未找到类型MyLog的属性getOne - Resolve org.springframework.data.mapping.PropertyReferenceException: No property getOne found for type MyLog org.springframework.data.mapping.PropertyReferenceException:未找到客户端类型的属性保存 - org.springframework.data.mapping.PropertyReferenceException: No property save found for type Client 引起:org.springframework.data.mapping.PropertyReferenceException:找不到类型User - Redis的属性findAll - Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type User - Redis Spring Data MongDB 2.1.0中的PropertyReferenceException - PropertyReferenceException in spring data mongdb 2.1.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM