gpt4 book ai didi

java - org.springframework.beans.factory.BeanDefinitionStoreException : Unexpected exception parsing XML document from ServletContext resource on spring app

转载 作者:太空宇宙 更新时间:2023-11-04 12:30:54 44 4
gpt4 key购买 nike

每当我启动应用程序时,Spring Web 上下文监听器都会遇到此问题。这是异常的完整堆栈跟踪

第一个堆栈跟踪

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;

在异常的第二行,我得到第二个堆栈跟踪

Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:81)

这是我的 spring-servlet.xml 文件的内容

<!-- Configuration defining views files -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/jsp/</value>
<!-- <value>/</value> -->
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- <tx:annotation-driven /> -->
<!-- <bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"></bean> -->
<mvc:resources mapping="/resources/js/**" location="/resources/js/" />
<mvc:resources mapping="/resources/css/**" location="/resources/css/" />
<!-- <aop:config>
<aop:aspect id="myaspect" ref="checkLogin1" >
@Before
<aop:pointcut id="pointCutBefore" expression="execution(* cntrlr.cntrlrUser..*(..))" />
<aop:before method="myadvice" pointcut-ref="pointCutBefore" />
</aop:aspect>
</aop:config> -->

<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/jsp/user/**"/>
<bean class="interceptor.CheckLogin" />
</mvc:interceptor>

</mvc:interceptors>

<mvc:annotation-driven />

我的 tomcat 拒绝启动我的应用程序。请问可能出了什么问题?

最佳答案

这是我的解决方案

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework-version}</version>
</dependency>

关于java - org.springframework.beans.factory.BeanDefinitionStoreException : Unexpected exception parsing XML document from ServletContext resource on spring app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37855587/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com