我正在使用Spring Boot 2.0.2进行Hibernate / lucene搜索时遇到问题

时间:2018-08-17 14:03:09

标签: hibernate spring-boot spring-data-jpa

实际上,我想在我的项目中实现Lucene搜索,但是在添加hibernate-search-orm.jar后出现以下异常 我使用的是spring-boot 2.0.2,spring-data-JPA和my-sql,因为数据库plz为此提供了帮助

  

08-17-2018 19:22:49 [WARN] ---上下文初始化期间遇到异常-取消刷新尝试: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

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

        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-search -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search</artifactId>
            <version>5.10.2.Final</version>
            <type>pom</type>

        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-search-orm -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search-orm</artifactId>
            <version>5.10.1.Final</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
</dependencies>

1 个答案:

答案 0 :(得分:0)

似乎您的pom.xml中缺少数据库驱动程序jar。请添加适当的jar,然后重新构建。

例如如果您使用的是postgres,则可能需要将其添加到pom中。

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
    </dependency>

对于oracle,请添加以下内容。

     <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>12.1.0.2</version>
    </dependency>

请确保在application.properties文件中配置了数据库属性。

相关问题