org.springframework.beans.factory.BeanCreationException:创建名为'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoSuchMethodError:org.springframework.web.bind.annotation.RequestMapping.path()[Ljava / lang / String;
引起:java.lang.NoSuchMethodError:org.springframework.web.bind.annotation.RequestMapping.path()[Ljava / lang / String;
几个小时以来一直坚持这个错误。
我的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.social</groupId>
<artifactId>sample-social</artifactId>
<name>ezhire</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<java-version>1.8</java-version>
<org.springframework-version>4.2.1.RELEASE</org.springframework-version>
<org.springframework.social-version>1.1.0.RELEASE</org.springframework.social-version>
<org.springframework.social.google-version>1.0.0.RELEASE</org.springframework.social.google-version>
<org.springframework.security-version>4.0.2.RELEASE</org.springframework.security-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Spring Social -->
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-google</artifactId>
<version>${org.springframework.social.google-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>${org.springframework.security-version}</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<!-- Logging -->
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Jade -->
<dependency>
<groupId>de.neuland-bfi</groupId>
<artifactId>spring-jade4j</artifactId>
<version>0.4.0</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
应用程序无法启动。所有spring框架依赖项都在相同的版本上,但仍然会出现相同的错误。
更新
mvn依赖的结果:树
[INFO] com.accolite:ezhire:war:1.0.0-BUILD-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:4.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.2.1.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.1.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.1.RELEASE:compile
[INFO] +- org.springframework.social:spring-social-core:jar:1.1.0.RELEASE:compil
e
[INFO] +- org.springframework.social:spring-social-web:jar:1.1.0.RELEASE:compile
[INFO] +- org.springframework.social:spring-social-google:jar:1.0.0.RELEASE:comp
ile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.3:compile
[INFO] | +- org.springframework.social:spring-social-config:jar:1.1.0.RELEASE:c
ompile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.3.3:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] +- org.springframework.security:spring-security-crypto:jar:4.0.2.RELEASE:
compile
[INFO] +- org.aspectj:aspectjrt:jar:1.6.10:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- de.neuland-bfi:spring-jade4j:jar:0.4.0:compile
[INFO] | +- de.neuland-bfi:jade4j:jar:0.4.0:compile
[INFO] | | +- org.apache.commons:commons-jexl:jar:2.1.1:compile
[INFO] | | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | | +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] | | +- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-l
ru:jar:1.3.1:compile
[INFO] | | \- org.pegdown:pegdown:jar:1.1.0:compile
[INFO] | | +- org.parboiled:parboiled-core:jar:1.0.2:compile
[INFO] | | \- org.parboiled:parboiled-java:jar:1.0.2:compile
[INFO] | | +- asm:asm:jar:3.3.1:compile
[INFO] | | +- asm:asm-util:jar:3.3.1:compile
[INFO] | | +- asm:asm-tree:jar:3.3.1:compile
[INFO] | | \- asm:asm-analysis:jar:3.3.1:compile
[INFO] | +- commons-io:commons-io:jar:2.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.6.0:compile
[INFO] +- junit:junit:jar:4.7:test
[INFO] +- org.springframework:spring-jdbc:jar:4.2.1.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.2.1.RELEASE:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.4:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.4:compile
[INFO] +- org.springframework:spring-core:jar:4.2.1.RELEASE:compile
[INFO] \- org.springframework:spring-web:jar:4.2.1.RELEASE:compile
在这里看起来一切都很好。
答案 0 :(得分:0)
我遇到了问题并解决了它。这是因为jar版本存在冲突。 我遇到问题的过程