pom.xml的名称为:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jvoid</groupId>
<artifactId>jvoidproducts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>jVoidProducts</name>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<!--<org.springframework-version>4.1.4.RELEASE</org.springframework-version>
<hibernate.version>4.2.16.Final</hibernate.version>-->
</properties>
<dependencies>
<dependency>
<groupId>com.jvoid</groupId>
<artifactId>persistenceapi</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.jvoid</groupId>
<artifactId>hibernate</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version><!--JavaEE7 onwards-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.0.0.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-asm</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.10</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.4.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.0.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<version>0.8.1</version>
<scope>test</scope>
</dependency>
<!-- Apache Commons DBCP -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!-- Spring ORM -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.10.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.10.Final</version>
</dependency>
</dependencies>
<build><finalName>${project.artifactId}</finalName></build>
</project>
在使用上面的pom运行项目时,我得到以下异常: 服务器使用Tomcat v6。
堆栈追踪:
javax.servlet.ServletException: Servlet.init() for servlet DispatcherServlet threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
root cause
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring/webcontext/DispatcherServlet-context.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.getEnvironment()Lorg/springframework/core/env/Environment;
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:223)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:194)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:676)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:642)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:690)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:558)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.getEnvironment()Lorg/springframework/core/env/Environment;
org.springframework.context.annotation.ComponentScanBeanDefinitionParser.configureScanner(ComponentScanBeanDefinitionParser.java:102)
org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1366)
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1352)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:178)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:148)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:98)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:223)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:194)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:676)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:642)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:690)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:558)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
上面的堆栈跟踪显示org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.getEnvironment()
方法不存在。它会在类configureScanner()
的方法org.springframework.context.annotation.ComponentScanBeanDefinitionParser
中显示第102行,并调用类getEnvironment()
的方法org.springframework.beans.factory.xml.BeanDefinitionParserDelegate
。
当我检查上述类的源代码时,我发现:
在课程ComponentScanBeanDefinitionParser
(发布 5.0.1.Release )中,在第102行(在方法configureScanner()
中),没有调用getEnvironment()
方法班级BeanDefinitionParserDelegate
。
但是当我检查时,我发现在发布 4.3.5。发布(或者它可能是 4.3.13 )时,它存在在线102 ,但之后的版本没有。
根据上面给出的pom我使用的是Spring版本5.0.1。请问为什么它调用以前版本的getEnvironment()方法(4.3.5.Release)?
上面错误堆栈调用跟踪的方法是(如我所检查的那样)(可能以任何方式回答):
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory() 在org.springframework.context.support.AbstractApplicationContext.refresh()中调用 在第454行,版本高达4.1.9但不是之后---------&gt; AbstractRefreshableApplicationContext.refreshBeanFactory()在540 upto调用 v4.1.9 -----&gt;调用XmlWebApplicationContext.loadBeanDefinitions() 在第129行到达 v5.0.0.RC2 --------&gt; XmlWebApplicationContext.loadBeanDefinitions()是 在第94行看到了 v5.0.1.Release ------&gt; AbstractBeanDefinitionReader.loadBeanDefinitions()在类XmlWebApplicationContext的125处调用 v5.0.1.Release ----&GT; AbstractBeanDefinitionReader.loadBeanDefinitions() 在AbstractBeanDefinitionReader的194中调用 v5.0.1.Release ----&GT; AbstractBeanDefinitionReader.loadBeanDefinitions() 在AbstractBeanDefinitionReader的223中调用 v5.0.1.Release -------------&gt; XmlBeanDefinitionReader.loadBeanDefinitions()在AbstractBeanDefinitionReader类的第187行调用 v5.0.1.Release -----&gt; XmlBeanDefinitionReader.loadBeanDefinitions()是 在XmlBeanDefinitionReader类的第303行调用 v5.0.1.Release ------------&GT; XmlBeanDefinitionReader.doLoadBeanDefinitions() 在类XmlBeanDefinitionReader的第335行调用 V5.0.1.Release -----------&gt; XmlBeanDefinitionReader.registerBeanDefinitions()在类XmlBeanDefinitionReader的第391行调用 v5.0.1.Release -------------&gt; DefaultBeanDefinitionDocumentReader.registerBeanDefinitions()在类XmlBeanDefinitionReader的第507行调用 v5.0.1.Release -----------&gt; DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions()在类DefaultBeanDefinitionDocumentReader的第98行调用 v5.0.1.Release ----------&GT; DefaultBeanDefinitionDocumentReader.arseBeanDefinitions() 在类DefaultBeanDefinitionDocumentReader的第148行调用 v5.0.1.Release ---------&gt; BeanDefinitionParserDelegate.parseCustomElement()在类DefaultBeanDefinitionDocumentReader的第178行调用 v5.0.1.Release ----------&GT; BeanDefinitionParserDelegate.parseCustomElement() 在BeanDefinitionParserDelegate类的第1352行调用 v5.0.1.Release --------&gt; NamespaceHandlerSupport.parse()被调用 BeanDefinitionParserDelegate类的第1366行 v5.0.1.Release --------&gt; ComponentScanBeanDefinitionParser.parse()是 在NamespaceNandlerSupport类的第74行调用 v5.0.1.Release ------------&GT; ComponentScanBeanDefinitionParser.configureScanner() 在ComponentScanBeanDefinitionParser类的第84行调用 v4.1.0.Release ---------&GT; BeanDefinitionParserDelegate.getEnvironment() 在ComponentScanBeanDefinitionParser类的第102行调用到
v4.1.0.Release
答案 0 :(得分:0)
使用mvn dependency:tree
,您可以检查哪些依赖项被拉入以及哪些传递依赖项被拉入。您可以使用它来获取调整内容的线索。