当前位置: 首页 > 知识库问答 >
问题:

Elasticsearch不会在Spring Boot中初始化

陆昕
2023-03-14

我正在将我的应用程序的Spring引导版本更新到一个版本,以防我使用1.3.2版本,我现在正在迁移到1.4.3。所以我的Elasticsearch给出了以下错误。

2017-06-01 10:41:28.449  WARN 12480 --- [ I/O worker #1}] org.elasticsearch.transport.netty        : [Maxam] exception caught on transport layer [[id: 0x12666e2c, /192.168.1.9:63584 => /XXX.XXX.XXX.XXX:9300]], closing connection

java.lang.NullPointerException: null
    at org.elasticsearch.transport.netty.MessageChannelHandler.handleException(MessageChannelHandler.java:179) ~[elasticsearch-2.4.3.jar:2.4.3]
    at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:174) ~[elasticsearch-2.4.3.jar:2.4.3]
    at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:122) ~[elasticsearch-2.4.3.jar:2.4.3]
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [netty-3.10.6.Final.jar:na]
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [netty-3.10.6.Final.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]

配置

@Configuration
public class SearchConfiguration {

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(elasticsearchClient());
    }

    @Bean
    public Client elasticsearchClient() throws UnknownHostException {

        Settings settings = Settings
                            .settingsBuilder()
                            .put("cluster.name", "production-1")
                            .build();

        InetAddress address = InetAddress.getByName("XXX.XXX.XXX.XXX");

        InetSocketTransportAddress transportAddress = new InetSocketTransportAddress(address, 9300);

        return TransportClient
                .builder()
                .settings(settings)
                .build()
                    .addTransportAddress(transportAddress);

    }

应用程序

@Configuration
@ComponentScan(basePackages = { "br.com.projectx" })
@EnableAutoConfiguration
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableElasticsearchRepositories(basePackages = { "br.com.projectx.devices.commands.search" })
@EnableRedisRepositories
@EnableAsync
public class Application { ... }

聚甲醛

<?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>

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

    <artifactId>projectx-endpoint-devices-commands</artifactId>
    <groupId>br.com.projectx</groupId>
    <description>Commands Endpoints</description>
    <version>1.0.0-SNAPSHOT</version>



    <properties>
        <main.basedir>${basedir}/../..</main.basedir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
       <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
       </dependency>
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-datastore</artifactId>
            <version>0.8.1-beta</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.jmethods</groupId>
            <artifactId>catatumbo</artifactId>
            <version>1.1.3</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>2.2.3</version>
        </dependency>

        <dependency>
            <groupId>com.github.fge</groupId>
            <artifactId>json-patch</artifactId>
            <version>1.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.skyscreamer</groupId>
            <artifactId>jsonassert</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>1.6.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-core</artifactId>
            <version>1.6.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>1.6.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.github.kstyrc</groupId>
            <artifactId>embedded-redis</artifactId>
            <version>0.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>

        <finalName>${project.artifactId}</finalName>
    </build>



</project>

共有1个答案

吕宇定
2023-03-14

springboot:1.4。3与elasticsearch 1不兼容。因此它依赖于spring数据elasticsearch:2.0。6.释放

您应该在2.0之间使用elasticsearch版本。0和5.0。0.参见Spring数据弹性搜索Spring启动版本矩阵

 类似资料:
  • 问题内容: 当我尝试启动Kibana时,我面临以下问题。我首先重新启动了我的Elasticsearch服务器,该服务器已成功运行。启动Elasticsearch之后,我尝试启动Kibana,但是没有运气。 提前致谢 问题答案: 警告:删除索引会使您 失去 所有kibana设置(索引,图形,仪表板) 这种现象有时是由现有索引引起的。请使用以下命令在elasticsearch中删除索引: 删除索引后,

  • 当我试图启动Kibana我面临以下问题。我首先重启了我的elasticsearch服务器,它运行成功。启动Elasticsearch后,我试图启动Kibana但没有成功。 提前谢谢

  • 我使用的是Spring框架和hibernate,我在其中映射了@OneToMany,当我加载类别来创建新产品时,我得到一个错误:在hibernate中用映射惰性地初始化集合失败,我以前看到过一些说明,请删除FectType。懒惰和我这样做了,但仍然没有效果 类别JAVA Product.java 我在用JPA 这是控制器的代码 product-form.jsp 但我得到错误 "我不知道哪里错了,我

  • 问题内容: 因此,我刚刚升级到Xcode 6.3 Beta 3,出现了许多与以下内容有关的错误: 初始化程序不会覆盖其父类中的指定初始化程序。 例如,这是一个类: 这是我的课程之一: 问题答案: 我的解决方案是一种快速解决方案,但我认为它比Apple在发行说明中的​​用途要容易。有关更多信息,请在此处搜索19775924 http://adcdownload.apple.com//Develope

  • 我在阅读这个问题的时候发现了backtype.storm.testing并感到很兴奋,但我一直无法使它工作,因为当我实际运行测试(从Java)时,测试类不会加载。 我想使用XuMingMing的TestingApiDemo中展示的测试函数,但当我实际运行测试时,我得到了一个ExceptionInInitializerError和一堆NoClassDefFoundErrors,因为它无法初始化Bac

  • 我使用的是spring-data-elasticsearch 2.2.0版本和ElasticSearch 2.2.0版本