今天Spring Cloud Gateway启动报错如下:
2019-07-12 14:32:58.824 ERROR 7192 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.AbstractMethodError: null
at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:141) ~[spring-core-5.0.13.RELEASE.jar:5.0.13.RELEASE]
at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65) ~[spring-core-5.0.13.RELEASE.jar:5.0.13.RELEASE]
at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:124) ~[spring-core-5.0.13.RELEASE.jar:5.0.13.RELEASE]
at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:112) ~[spring-core-5.0.13.RELEASE.jar:5.0.13.RELEASE]
at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:81) ~[spring-core-5.0.13.RELEASE.jar:5.0.13.RELEASE]
at org.springframework.core.OrderComparator.compare(OrderComparator.java:68) ~[spring-core-5.0.13.RELEASE.jar:5.0.13.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:1308) [spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at org.springframework.boot.SpringApplication.getListeners(SpringApplication.java:1218) [spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85) ~[spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66) ~[spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:382) [spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) [spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.9.RELEASE.jar:2.0.9.RELEASE]
at com.zp.gateway.GatewayApplication.main(GatewayApplication.java:12) [classes/:na]
Process finished with exit code 1
网上说是版本的原因,我试了下,确实是版本的问题。我的spring boot 用的是2.0.9.RELEASE,spring-cloud-starter-gateway用的是2.1.1.RELEASE,这两个不匹配所以报错,两种解决方案,降低spring-cloud-starter-gateway到2.0.x或者升高spring boot的版本到2.1.x即可。