我正在研究一批,我遇到了一个问题 . 我已经确定了我的问题的原因,但我无法解决它 .
一旦我在我的pom中添加依赖项,我就会开始出错
maven依赖是
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
我的pom如下所示
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.edf.fr.batch</groupId>
<artifactId>edf-batch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我得到的错误就是这个
java.lang.NoClassDefFoundError:org.springframework.data.jpa.util.BeanDefinitionUtils中的javax / persistence / EntityManagerFactory . (BeanDefinitionUtils.java:53)〜[spring-data-jpa-1.11.6.RELEASE.jar:na]在org.springframework.data.jpa.repository.support.EntityManagerBeanDefinitionRegistrarPostProcessor.postProcessBeanFactory(EntityManagerBeanDefinitionRegistrarPostProcessor.java:54)〜[spring-data-jpa-1.11.6.RELEASE.jar:na] at org.springframework.context.support . PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:281)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:176)〜 [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]在org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)~ [spring-context-4.3.10.RELEASE . jar :4 . 3.10.RELEASE]在org.springframework.boot上的org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] . SpringApplication.refresh(SpringApplication.java:693)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)[spring-boot -1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE在org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] org.springframework.boot.SpringApplication.run(SpringApplication . java:1107)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at com.edf.fr.batch.MarcheBatchApplication.main(MarcheBatchApplication.java:10)[classes /:na]引起的:java.lang.ClassNotFoundException:java中的javax.persistence.EntityManagerFactory . net.URLClassLoader.findClass(URLClassLoader.java:381)〜[na:1.8.0_60] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0_60] at sun.misc.Launcher $ java.lang.ClassLoader.loadClass的AppClassLoader.loadClass(Launcher.java:331)〜[na:1.8.0_60]〜[na:1.8.0_60] ...省略了12个常见帧2017- 08-14 16:18:43.676 INFO 11676 --- [main] scaAnnotationConfigApplicationContext:关闭org.springframework.context.annotation.AnnotationConfigApplicationContext@48a242ce:启动日期[Mon Aug 14 16:18:42 CEST 2017];上下文层次结构的根源2017-08-14 16:18:43.677 WARN 11676 --- [main] scaAnnotationConfigApplicationContext:从上下文关闭的LifecycleProcessor抛出的异常java.lang.IllegalStateException:LifecycleProcessor未初始化 - 在调用生命周期方法之前调用'refresh'通过上下文:org.springframework.context.annotation.AnnotationConfigApplicationContext@48a242ce:启动日期[Mon Aug 14 16:18:42 CEST 2017]; org.springframework.context.support上的org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:427)[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]的上下文层次结构的根.AbstractApplicationContext.doClose(AbstractApplicationContext.java:999)[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)[ spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)[spring-boot-1.5.6.RELEASE.jar:1.5 . 6.RELEASE] org.springframework.boot.SpringApplication.run(SpringApplication.java:314)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] org.springframework.boot.SpringApplication.run (SpringApplication.java:1118)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)[spring-boo t-1.5.6.RELEASE.jar:1.5.6.RELEASE] at com.edf.fr.batch.MarcheBatchApplication.main(MarcheBatchApplication.java:10)[classes /:na] 2017-08-14 16:18: 43.678 ERROR 11676 --- [main] osbfsDefaultListableBeanFactory:名为'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory'的bean上的Destroy方法抛出异常java.lang.IllegalStateException:ApplicationEventMulticaster未初始化 - 在多播事件之前调用'refresh'上下文:org.springframework.context.annotation.AnnotationConfigApplicationContext@48a242ce:启动日期[Mon Aug 14 16:18:42 CEST 2017];上下文层次结构的根org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:414)[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction( ApplicationListenerDetector.java:97)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]在org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)〜[spring -beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)[spring-beans-4.3.10.RELEASE.jar :4.3.10.RELEASE]在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org . springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:96 1)[org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons中的[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] [spring-beans-4.310] .RELEASE.jar:4.3.10.RELEASE] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:230)[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE ] org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] org.springframework.context.support . AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030)[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006)[chring -context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.close(AbstractAppli cationContext.java:958)[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)[chring-boot-1.5.6 .RELEASE.jar:1.5.6.RELEASE] org.springframework.boot.SpringApplication.run(SpringApplication.java:314)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org . springframework.boot.SpringApplication.run(SpringApplication.java:1118)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]在com.edf.fr.batch.MarcheBatchApplication.main(MarcheBatchApplication.java:10)[classes /:na]
1 回答
从给定的堆栈跟踪中你可以看到找不到某些类,因为你使用的是spring引导,spring引用使用包含多个依赖项的meta依赖项,如spring-boot-cookbook中所述
spring-data-jpa是不够的,还有一些你需要的依赖,使用
spring-boot-starter-data-jpa