启动eureka工程报java.lang.AbstractMethodError: null异常
java.lang.AbstractMethodError: null at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:142) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:125) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:113) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:82) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.core.OrderComparator.compare(OrderComparator.java:68) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360) ~[na:1.8.0_181] at java.util.TimSort.sort(TimSort.java:220) ~[na:1.8.0_181] at java.util.Arrays.sort(Arrays.java:1512) ~[na:1.8.0_181] at java.util.ArrayList.sort(ArrayList.java:1462) ~[na:1.8.0_181] at org.springframework.boot.SpringApplication.asUnmodifiableOrderedSet(SpringApplication.java:1322) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.getListeners(SpringApplication.java:1231) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:391) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at com.itcast.EurekaSpringBootRun.main(EurekaSpringBootRun.java:12) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.3.RELEASE.jar:2.0.3.RELEASE]
此bug一般是因为Spring Boot版本与Spring Cloud版本不匹配导致,我搭建Eureka环境时用的springBoot版本是 2.0.3.RELEASE,springCloud版本是 Greenwich.SR4
以下为错误版本冲突示范,切勿CV
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> </parent>
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Greenwich.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
解决方法是我把Spring Boot版本改为2.1.3.RELEASE就可以啦!
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.RELEASE</version> </parent>