java - Maven 阴影插件 ClassNotFoundException

  显示原文与译文双语对照的内容
0 0

我正在尝试使用 Maven 阴影插件。

我正在使用:java5,spring 4.1.6,版本,Hibernate 4.3.9 final,maven-shade插件版本 2.3

我有以下错误。 无法找出问题。

 BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [other/project/persistence/jpa/EntityManagerFactoryProvider.class]: Invocation of init method failed; nested exception is java.lang.TypeNotPresentException: Type java.time.LocalTime not present
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:523)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:512)
 at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1052)
 at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:227)
 at org.springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.getMetamodels(JpaMetamodelMappingContextFactoryBean.java:85)
 at org.springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:56)
 at org.springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:26)
Caused by: java.lang.TypeNotPresentException: Type java.time.LocalTime not present
 at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(Unknown Source)
 at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Unknown Source)
 at sun.reflect.generics.tree.ClassTypeSignature.accept(Unknown Source)
 at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Unknown Source)
 at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Unknown Source)
 at sun.reflect.generics.tree.ClassTypeSignature.accept(Unknown Source)
 at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(Unknown Source)
 at java.lang.Class.getGenericInterfaces(Unknown Source)
 at org.hibernate.cfg.AttributeConverterDefinition.extractAttributeConverterParameterizedType(AttributeConverterDefinition.java:85)
 at org.hibernate.cfg.AttributeConverterDefinition.<init>(AttributeConverterDefinition.java:52)
 at org.hibernate.cfg.Configuration.addAttributeConverter(Configuration.java:2729)
 at org.hibernate.cfg.Configuration.addAttributeConverter(Configuration.java:2673)
 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1153)
 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:853)
 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
 at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
 at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
 at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
 at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
] 
Caused by: java.lang.ClassNotFoundException: java.time.LocalTime
 at java.net.URLClassLoader$1.run(Unknown Source)
]

编辑: 发现问题,但仍然没有解决问题: 我正在使用 org.threeten.threetenbp的LocalDate并设置了 jadira 。usertype 。autoregisterusertypes=true 。 就像我所说的,运行IntelliJ的主类时运行正常,但在执行 jar 时运行。

时间:原作者:3个回答

0 0

java.time.LocalTime 出现在Java8所以可能取决于正在使用一些库类Java8(根据你的堆栈跟踪,这是 Hibernate )

原作者:
0 0

在 Java 8中引入了 java.lang.LocalTime的依赖关系。

因为你使用的是 Java 7,所以得到了一个 ClassNotFoundException 。 switch 到 Java 8或者替换引入依赖项的库。

原作者:
...