版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36135928/article/details/85199141
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hdpos-repository.emf' defined in class path resource [META-INF/application.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: INSTANCE
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
...
Caused by: java.lang.NoSuchFieldError: INSTANCE
at org.hibernate.type.BasicTypeRegistry.<init>(BasicTypeRegistry.java:94)
at org.hibernate.type.TypeResolver.<init>(TypeResolver.java:59)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:250)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:302)
at org.hibernate.cfg.AnnotationConfiguration.<init>(AnnotationConfiguration.java:87)
at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.java:133)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
在pom文件中查看冲突
解决办法:exclusion排除依赖
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
</dependency>