服务端ES版本为5.5.2,springboot版本为1.5.6。java
工程中添加以下依赖spring
报错java.lang.ClassNotFoundException: org.elasticsearch.plugins.NetworkPluginapi
和java.lang.NoClassDefFoundError: org/elasticsearch/plugins/NetworkPluginspringboot
问题分析:elasticsearch
在biz模块引入了5.5.2版本的es client jar,能找到对应的类maven
查看api模块的war中的es client jar版本确实不是5.5.2,而是springboot默认的2.4.5,此版本确实是没有NetworkPlugin这个类的。ide
这里涉及到maven的Dependency management 的两个做用,其中第二个方面就解释了为何出现jar包版本的问题this
1)It is a central place for defining versions of dependencies. So when an artifact version is defined in the <dependencyManagement> section you can declare the dependency in your pom without defining the version, and the version defined in <dependencyManagement> will be used automatically. Example 1 Let's say your parent pom defined the following <dependencyManagement> <dependencies> <dependency> <groupId>com.mememe</groupId> <artifactId>mylib</artifactId> <version>1.1.12</version> </dependency> </dependencies> </dependencyManagement> Then if you define the following in your pom <dependencies> <dependency> <groupId>com.mememe</groupId> <artifactId>mylib</artifactId> </dependency> </dependencies> Your project will automatically use version 1.1.12 as defined in the <dependencyManagement> section of your parent pom. 2)Overriding the versions of transitive dependencies. If you have an artifact version defined in your <dependencyManagement> and one of your dependencies has a transitive dependency on the same artifact, the version of the artifact defined in your <dependencyManagement> section is used automatically. Example 2 Let's say this artifact <dependency> <groupId>com.youyou</groupId> <artifactId>yourlib</artifactId> <version>3.0.0</version> </dependency> Has this transitive dependency <dependency> <groupId>com.morestuff</groupId> <artifactId>morelib</artifactId> <version>2.0.0</version> </dependency> Now let's say our parent pom defines this <dependencyManagement> section <dependencyManagement> <dependencies> <dependency> <groupId>com.morestuff</groupId> <artifactId>morelib</artifactId> <version>2.5.2</version> </dependency> </dependencies> </dependencyManagement> Then if you define this dependency in your pom <dependency> <groupId>com.youyou</groupId> <artifactId>yourlib</artifactId> <version>3.0.0</version> </dependency> Maven will override yourlib's dependency on morelib version 2.0.0 with morelib version 2.5.2.
参考:url
解决办法就是在api模块的pom文件中再一次添加依赖
报错
Exception in thread "elasticsearch[_client_][management][T#1]" java.lang.AbstractMethodError:
极光推送的客户端jar包也引入了netty
去掉便可