【问题标题】:spring boot elastic search -configure data sourcespring boot弹性搜索-配置数据源
【发布时间】:2018-02-01 02:40:04
【问题描述】:

我正在尝试配置 Spring Data Boot Sand ES 项目 在我的 pom.xml 我有:

@Configuration
 @EnableElasticsearchRepositories(basePackages = "com.yoyo.elastic.repository")
 public class ElasticConfiguration {


@Bean
public NodeBuilder nodeBuilder() {
    return new NodeBuilder();
}




@Bean
public ElasticsearchOperations elasticsearchTemplate() throws IOException {
    File tmpDir = File.createTempFile("elastic", Long.toString(System.nanoTime()));
    System.out.println("Temp directory: " + tmpDir.getAbsolutePath());

    final Client client = nodeBuilder().local(true).node().client();
    return  new ElasticsearchTemplate(client);
}

}

在我的 pom xml 中,我有这个 dep:

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

这应该可以满足驱动程序,但我不断得到: 说明:

无法确定数据库类型 NONE 的嵌入式数据库驱动程序类

行动:

如果您想要一个嵌入式数据库,请在类路径中放置一个受支持的数据库。如果您要从特定配置文件加载数据库设置,您可能需要激活它(当前没有配置文件处于活动状态)。

【问题讨论】:

    标签: spring-boot spring-data-elasticsearch


    【解决方案1】:

    我在尝试使用 Spring Boot 和 ElasticSearch 进行一些练习时遇到了同样的问题。

    现在我想如果你有

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

    除了spring-boot-starter-data-elasticsearch 并且不要添加其他配置类(您将在其中配置数据源)spring boot 会报错。

    其他解决方案是实际将数据源属性添加到 application.properties 并配置独立数据库(如 H2)

    【讨论】:

      猜你喜欢
      • 2018-06-08
      • 2014-11-04
      • 2020-10-22
      • 1970-01-01
      • 2016-01-17
      • 2015-01-26
      • 2021-12-12
      相关资源
      最近更新 更多