无法访问其超类 org.javers.spring.jpa.JaversTransactionalDecorator

Cannot access its superclass org.javers.spring.jpa.JaversTransactionalDecorator

使用当前保护程序时出现以下错误spring 引导启动器实现 (v 2.0.2)

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'javersAuditableRepositoryAspect' defined in class path resource [org/javers/spring/boot/sql/JaversSqlAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.javers.core.Javers]: Error creating bean with name 'javers' defined in class path resource [org/javers/spring/boot/sql/JaversSqlAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class org.javers.spring.jpa.JaversTransactionalDecorator]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'javers' defined in class path resource [org/javers/spring/boot/sql/JaversSqlAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class org.javers.spring.jpa.JaversTransactionalDecorator]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory.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:197)
    at org.springframework.aop.aspectj.annotation.BeanFactoryAspectInstanceFactory.getAspectInstance(BeanFactoryAspectInstanceFactory.java:80)
    at org.springframework.aop.aspectj.annotation.LazySingletonAspectInstanceFactoryDecorator.getAspectInstance(LazySingletonAspectInstanceFactoryDecorator.java:54)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:620)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:602)
    at org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:62)
    at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:53)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:68)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
    at com.sun.proxy.$Proxy161.save(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
    ... 23 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'javers' defined in class path resource [org/javers/spring/boot/sql/JaversSqlAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class org.javers.spring.jpa.JaversTransactionalDecorator]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory.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:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 51 common frames omitted
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class org.javers.spring.jpa.JaversTransactionalDecorator]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:207)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:468)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:349)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:298)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    ... 61 common frames omitted
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:328)
    at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:445)
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.apply(AbstractClassGenerator.java:85)
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.apply(AbstractClassGenerator.java:83)
    at org.springframework.cglib.core.internal.LoadingCache.call(LoadingCache.java:54)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
    at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:105)
    at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:278)
    at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:433)
    at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:338)
    at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:55)
    at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:203)
    ... 68 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:409)
    at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:319)
    ... 81 common frames omitted
Caused by: java.lang.IllegalAccessError: class org.javers.spring.jpa.JaversTransactionalDecorator$$EnhancerBySpringCGLIB$c0aeeb8 cannot access its superclass org.javers.spring.jpa.JaversTransactionalDecorator
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    ... 86 common frames omitted

我的 POM 有

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.javers</groupId>
    <artifactId>javers-spring-boot-starter-sql</artifactId>
    <version>2.0.2</version>
</dependency>

Application.yml 文件有

javers:
  mapping-style: BEAN

这是我正在使用的自定义 AuthorProvider...

@Component
public class JaversSpringAuthorProvider implements AuthorProvider {
    @Override
    public String provide() {
        UserPrincipal principal = (UserPrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if (principal == null) {
            return AuthoritiesConstants.SYSTEM_USER;
        }
        return String.valueOf(principal.getUserKey());
    }
}

我也在使用 HikariCP 创建数据源

抛出错误之前的一些启动日志是...

2016-06-24 15:20:17.405  INFO 17706 --- [  restartedMain] o.j.s.b.sql.JaversSqlAutoConfiguration   : detected Hibernate dialect: H2Dialect
2016-06-24 15:20:17.413  INFO 17706 --- [  restartedMain] o.j.repository.sql.SqlRepositoryBuilder  : starting up SQL repository module ...
2016-06-24 15:20:17.515  INFO 17706 --- [  restartedMain] org.javers.java8support.Java8AddOns      : loading Java8 add-ons ...
2016-06-24 15:20:17.532  INFO 17706 --- [  restartedMain] org.javers.groovysupport.GroovyAddOns    : loading Groovy add-ons ...
2016-06-24 15:20:17.540  INFO 17706 --- [  restartedMain] o.j.c.metamodel.scanner.ScannerModule    : using BEAN mappingStyle
2016-06-24 15:20:17.620  INFO 17706 --- [  restartedMain] o.j.s.jpa.TransactionalJaversBuilder     : JaVers transactional decorator is ready
2016-06-24 15:20:17.640  INFO 17706 --- [  restartedMain] o.j.r.sql.schema.JaversSchemaManager     : creating javers table jv_commit ...
2016-06-24 15:20:17.640  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_commit using ddl:
CREATE TABLE jv_commit (
commit_pk BIGINT NOT NULL,
author VARCHAR(200),
commit_date TIMESTAMP,
commit_id NUMERIC(12,2),
CONSTRAINT jv_commit_pk PRIMARY KEY(commit_pk)
) 
2016-06-24 15:20:17.642  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_commit_commit_id_idx using ddl:
CREATE INDEX jv_commit_commit_id_idx ON jv_commit(commit_id)
2016-06-24 15:20:17.643  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_commit_pk_seq using ddl:
CREATE SEQUENCE jv_commit_pk_seq
2016-06-24 15:20:17.644  INFO 17706 --- [  restartedMain] o.j.r.sql.schema.JaversSchemaManager     : creating javers table jv_commit_property ...
2016-06-24 15:20:17.644  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_commit_property using ddl:
CREATE TABLE jv_commit_property (
property_name VARCHAR(200),
property_value VARCHAR(200),
commit_fk BIGINT,
CONSTRAINT jv_commit_property_pk PRIMARY KEY(commit_fk, property_name),
CONSTRAINT jv_commit_property_commit_fk FOREIGN KEY(commit_fk) REFERENCES jv_commit(commit_pk)
) 
2016-06-24 15:20:17.646  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_commit_property_commit_fk_idx using ddl:
CREATE INDEX jv_commit_property_commit_fk_idx ON jv_commit_property(commit_fk)
2016-06-24 15:20:17.647  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_commit_property_property_name_property_value_idx using ddl:
CREATE INDEX jv_commit_property_property_name_property_value_idx ON jv_commit_property(property_name,property_value)
2016-06-24 15:20:17.648  INFO 17706 --- [  restartedMain] o.j.r.sql.schema.JaversSchemaManager     : creating javers table jv_global_id ...
2016-06-24 15:20:17.648  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_global_id using ddl:
CREATE TABLE jv_global_id (
global_id_pk BIGINT NOT NULL,
local_id VARCHAR(200),
fragment VARCHAR(200),
type_name VARCHAR(200),
owner_id_fk BIGINT,
CONSTRAINT jv_global_id_pk PRIMARY KEY(global_id_pk),
CONSTRAINT jv_global_id_owner_id_fk FOREIGN KEY(owner_id_fk) REFERENCES jv_global_id(global_id_pk)
) 
2016-06-24 15:20:17.650  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_global_id_local_id_idx using ddl:
CREATE INDEX jv_global_id_local_id_idx ON jv_global_id(local_id)
2016-06-24 15:20:17.650  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_global_id_pk_seq using ddl:
CREATE SEQUENCE jv_global_id_pk_seq
2016-06-24 15:20:17.651  INFO 17706 --- [  restartedMain] o.j.r.sql.schema.JaversSchemaManager     : creating javers table jv_snapshot ...
2016-06-24 15:20:17.651  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_snapshot using ddl:
CREATE TABLE jv_snapshot (
snapshot_pk BIGINT NOT NULL,
type VARCHAR(200),
version BIGINT,
state TEXT,
changed_properties TEXT,
managed_type VARCHAR(200),
global_id_fk BIGINT,
commit_fk BIGINT,
CONSTRAINT jv_snapshot_pk PRIMARY KEY(snapshot_pk),
CONSTRAINT jv_snapshot_global_id_fk FOREIGN KEY(global_id_fk) REFERENCES jv_global_id(global_id_pk),
CONSTRAINT jv_snapshot_commit_fk FOREIGN KEY(commit_fk) REFERENCES jv_commit(commit_pk)
) 
2016-06-24 15:20:17.653  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_snapshot_global_id_fk_idx using ddl:
CREATE INDEX jv_snapshot_global_id_fk_idx ON jv_snapshot(global_id_fk)
2016-06-24 15:20:17.654  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_snapshot_commit_fk_idx using ddl:
CREATE INDEX jv_snapshot_commit_fk_idx ON jv_snapshot(commit_fk)
2016-06-24 15:20:17.654  INFO 17706 --- [  restartedMain] o.p.core.schema.SchemaManagerImpl        : creating entity with name jv_snapshot_pk_seq using ddl:
CREATE SEQUENCE jv_snapshot_pk_seq
2016-06-24 15:20:17.677  WARN 17706 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization

存储库已使用@JaversSpringDataAuditable 进行注释,并且未进行其他代码更改以与 Javers 集成。我按照 http://javers.org/documentation/spring-boot-integration/ 中的建议进行了更改,所以如果我在这里遗漏了什么,请告诉我。

更新 1:

我进一步调查了这个问题,发现当我们对类路径有以下 spring 依赖时,就会发生这个问题 -

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
    <version>1.1.0.RELEASE</version>
</dependency>

这已作为 2.0.3 版本的一部分得到修复 - https://github.com/javers/javers/issues/396