与其他依赖项之间的休眠搜索冲突

时间:2018-07-10 10:49:58

标签: java spring-boot hibernate-search

在pom.xml文件中添加 org.hibernate 依赖项时出现问题

<?xml version="1.0" encoding="UTF-8"?>
<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.xxx</groupId>
    <artifactId>get-user-permissions</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
        <relativePath /> 
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>jdk.tools</groupId>
            <artifactId>jdk.tools</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.5</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>    

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.0</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.2</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>


        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version><!--$NO-MVN-MAN-VER$ -->
            <scope>provided</scope>
        </dependency>


        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-crypto</artifactId>
            <version>5.0.5.RELEASE</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.11</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search-orm</artifactId>
            <version>5.10.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

由错误消息引起的错误列表

  

[ERROR] 2018-07-10 15:48:45.908 [main]   org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:842)   -应用程序运行失败       org.springframework.beans.factory.BeanCreationException:在类路径中创建名称为'entityManagerFactory'的bean时出错   资源   [org / springframework / boot / autoconfigure / orm / jpa / HibernateJpaConfiguration.class]:   调用init方法失败;嵌套异常为   java.lang.NoClassDefFoundError:   org / hibernate / resource / beans / spi / ManagedBeanRegistry         在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]         在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]         在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]         在org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]         在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]         在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]         在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]         在org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089)   〜[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]         

     

org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859)   〜[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)   〜[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)   〜[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]             在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)   [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]             在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)   [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]             在org.springframework.boot.SpringApplication.run(SpringApplication.java:327)   [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]             在org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)   [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]             在org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)   [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]             在com.greydelta.GreydeltaErpApplication.main(GreydeltaErpApplication.java:19)   [课程/ :?]           造成原因:java.lang.NoClassDefFoundError:org / hibernate / resource / beans / spi / ManagedBeanRegistry             在org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:55)   〜[hibernate-search-orm-5.10.2.Final.jar:5.10.2.Final]             在org.hibernate.internal.SessionFactoryImpl。(SessionFactoryImpl.java:281)   〜[hibernate-core-5.2.17.Final.jar:5.2.17.Final]             在org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)   〜[hibernate-core-5.2.17.Final.jar:5.2.17.Final]             在org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892)   〜[hibernate-core-5.2.17.Final.jar:5.2.17.Final]             在org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57)处   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1765)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]             ...另外16个           引起原因:java.lang.ClassNotFoundException:org.hibernate.resource.beans.spi.ManagedBeanRegistry             在java.net.URLClassLoader.findClass(未知来源)〜[?:1.8.0_171]             在java.lang.ClassLoader.loadClass(未知来源)〜[?:1.8.0_171]             在sun.misc.Launcher $ AppClassLoader.loadClass(未知来源)〜[?:1.8.0_171]             在java.lang.ClassLoader.loadClass(未知来源)〜[?:1.8.0_171]             在org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:55)   〜[hibernate-search-orm-5.10.2.Final.jar:5.10.2.Final]             在org.hibernate.internal.SessionFactoryImpl。(SessionFactoryImpl.java:281)   〜[hibernate-core-5.2.17.Final.jar:5.2.17.Final]             在org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)   〜[hibernate-core-5.2.17.Final.jar:5.2.17.Final]             在org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892)   〜[hibernate-core-5.2.17.Final.jar:5.2.17.Final]             在org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57)处   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)   〜[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1765)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]             在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702)   〜[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]             ...还有16个

1 个答案:

答案 0 :(得分:6)

5.9.2。最终

在pom.Xml文件中使用此版本。 不要使用5.10.2