搜尋

首頁  >  問答  >  主體

java - springmvc 和velocity 配置 报错NoClassDefFoundError

spring 4.1.6.RELEASE maven方式.
报错如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.geekworld.service.AccountService org.geekworld.controller.AccountController.accountService; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.web.servlet.view.velocity.VelocityConfigurer] for bean with name 'velocityConfig' defined in class path resource [spring-servlet.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory
配置为:
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">

    <property name="resourceLoaderPath" value="/WEB-INF"/>
    <property name="configLocation" value="classpath:velocity.properties"/>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
    <property name="suffix" value=".vm"/>
    <property name="prefix" value="/"/>
    <!-- 使用springMacro的对象 -->
    <property name="exposeSpringMacroHelpers" value="true"/>
    <property name="requestContextAttribute" value="content"/>
    <property name="exposeRequestAttributes" value="true"/>
    <property name="exposeSessionAttributes" value="true"/>
    <property name="contentType" value="text/html;charset=UTF-8"/>
    <!-- spring的日期格式化 -->
    <property name="dateToolAttribute" value="dateTool"/>
    <!-- velocity toolbox -->
    <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
</bean>

黄舟黄舟2803 天前819

全部回覆(1)我來回復

  • 巴扎黑

    巴扎黑2017-04-17 17:31:36

    spring-context套件引入一下吧

    回覆
    0
  • 取消回覆