java.lang.NoClassDefFoundError:org.mvel2.integration.VariableResolverFactory

时间:2018-12-05 16:59:50

标签: java spring spring-mvc applicationcontext

我从项目中得到了这个运行时错误

[12/5/18 11:54:35:045 EST] 00000104 XmlWebApplica W org.springframework.context.support.AbstractApplicationContext refresh Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/applicationsweb-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org.mvel2.integration.VariableResolverFactory
[12/5/18 11:54:35:048 EST] 00000104 DispatcherSer E org.springframework.web.servlet.FrameworkServlet initServletBean Context initialization failed
                                 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/applicationsweb-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org.mvel2.integration.VariableResolverFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

我的ApplicationContext看起来像这样,

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Resolves views selected for rendering by @Controllers to tiles resources -->
    <beans:bean id="viewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"/>

    <beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer" >       
        <beans:property name="completeAutoload" value="true"/>
        <beans:property name="definitions">
            <beans:list>
                  <beans:value>/WEB-INF/defs/tiles-defs.xml</beans:value>                 
            </beans:list>
        </beans:property>
    </beans:bean>
</beans:beans>

我在webInf库和EAR库中都有spring-webmvc-4.2.6.RELEASE.jar。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

错误提示它找不到某个类,这意味着您在该类所在的位置没有jar

只需添加以下jar文件: https://mvnrepository.com/artifact/org.mvel/mvel2