Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoSuchMethodError:org.springframework.web.context.request.ServletRequestAttributes;初始化>;_Java_Spring_Spring Mvc_Nosuchmethoderror - Fatal编程技术网

java.lang.NoSuchMethodError:org.springframework.web.context.request.ServletRequestAttributes;初始化>;

java.lang.NoSuchMethodError:org.springframework.web.context.request.ServletRequestAttributes;初始化>;,java,spring,spring-mvc,nosuchmethoderror,Java,Spring,Spring Mvc,Nosuchmethoderror,从Spring 3迁移到Spring 4后,在请求页面时出现以下错误: java.lang.NoSuchMethodError: org.springframework.web.context.request.ServletRequestAttributes.<init>(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V dispatcherservlet.xml:

从Spring 3迁移到Spring 4后,在请求页面时出现以下错误:

java.lang.NoSuchMethodError: org.springframework.web.context.request.ServletRequestAttributes.<init>(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
dispatcherservlet.xml


/模板/
.jsp
和my
pom.xml


4.0.0
javacms
javacms
战争
0.0.1-快照
javacms Maven Webapp
http://maven.apache.org
4.1.7.1发布
4.0.1.1发布
朱尼特
朱尼特
4.12
org.springframework
弹簧芯
${spring.version}
org.springframework
弹簧网
${spring.version}
org.springframework
SpringWebMVC
${spring.version}
org.springframework
spring上下文
${spring.version}
org.springframework
春豆
${spring.version}
javax.servlet
jstl
1.2
org.springframework.security
spring安全内核
${spring security.version}
org.springframework.security
spring安全标记库
${spring security.version}
org.springframework.security
spring安全配置
${spring security.version}
mysql
mysql连接器java
5.1.36
org.hibernate
冬眠核心
4.3.10.最终版本
网络应用

我是缺少依赖项还是有一些错误的版本?

此错误
java.lang.NoSuchMethodError:org.springframework.web.context.request.ServletRequestAttributes。(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
表示您正在使用最新版本的spring,并且您正在尝试从spring 3调用较旧版本的
ServletRequestAttributes

查看javadoc:

我猜Spring4使用的是较旧版本的jar,它包含
ServletRequestAttributes
。检查您的库并查看是否存在冲突

尝试将此添加到pom.xml:

  <build>
    <finalName>WebApp</finalName>
        <plugins>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
             <source>1.7</source> 
             <target>1.7</target> 
        </configuration>
    </plugin>
    </plugins>
  </build>

网络应用
maven编译器插件
3.1
1.7
1.7

我通过使用apache httpclient较新的4.5.9而不是4.5.6解决了这个版本问题,Maven pom显示了一个过度隐藏警告。

您确定类路径中存在所需的JAR吗?在Java构建路径->库->Maven依赖项下,pom中定义的所有JAR都是列表的。spring库的版本是4.1.7.RELEASE,Eclipse没有显示任何错误。您是否运行此应用程序?也许在web服务器上有一些旧版本的libriary正在你的纸牌屋里捣乱。Eclipse是一回事,运行时是另一回事。尝试从Spring 3中删除您的LIB,无论您发现了什么。右键单击project->Run on Server(tomcat)我注意到了以下错误:一个或多个约束未得到满足(类型:Maven Java EE配置问题),但我无法获得任何进一步的信息。Eclipse是一回事,运行时是另一回事。尝试从Spring3中消除你的LIB,无论你发现了什么。更新答案。请将此添加到pom.xml。一次又一次。