異常詳情:
Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.servlet.handler.AbstractHandlerMapping.obtainApplicationContext()Lorg/springframework/context/ApplicationContext;
參考https://blog.csdn.net/u012527870/article/details/81843504,找到原因在於spring的jar包版本沖突
該項目里的spring依賴版本都是5.1.4
<!--參數管理--> <properties> <jdk.version>1.8</jdk.version> <spring.version>5.1.4.RELEASE</spring.version> </properties> <!--依賴管理--> <dependencies> …… <!--spring--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> <version>${spring.version}</version> </dependency> …… <!--activemq--> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.15.8</version> </dependency> </dependencies>
而該項目引入的另一個依賴(activemq-all),本身又依賴了另一個版本的spring
<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/maven-v4_0_0.xsd"> <groupId>org.apache.activemq</groupId> <artifactId>activemq-parent</artifactId> <version>5.15.8</version> <packaging>pom</packaging> <name>ActiveMQ</name> <inceptionYear>2005</inceptionYear> <!--這里的spring版本是4.3.18--> <spring-version>4.3.18.RELEASE</spring-version>
……
</project>
解決方案:
1. 將該項目依賴的spring版本改為4.3.18
2. 在該項目中引入activemq-all依賴時,排除掉spring
