JAva.lang.IllegalStateException:availableProcessors is already set to[4]、rejecting[4]解決、実測有効

3443 ワード

<dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-data-elasticsearchartifactId>
dependency>

<spring-boot.version>2.0.1.RELEASEspring-boot.version>
    :
java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]

解決策は次のとおりです.
package net.zjdata.similarity.conf;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
/**
 * @author lasse
 * @modified by
 * @Date 14:06 2018/7/2
 * @Description ElasticSearch  
 */
@Configuration
public class ElasticSearchConfig {
    /**
     *   netty bug
     * java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
     */
    @PostConstruct
    void init() {
        System.setProperty("es.set.netty.runtime.available.processors", "false");
    }
}

上記の方法で解決できない場合は、以下の方法で解決してください.
@ComponentScan("com.flnet")
@SpringBootApplication
@EnableTransactionManagement
@MapperScan("com.flnet.ms.cms.**.dao")
//@ImportResource({"classpath:disconf.xml"})
public class CmsMediaApplication {

    public static void main(String[] args) {
        /**
         * Springboot  Elasticsearch              ,    
         *   netty      client       
         * java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
         */
        System.setProperty("es.set.netty.runtime.available.processors", "false");
        SpringApplication.run(CmsMediaApplication.class, args);
    }
}

springbootの起動クラスに追加