찾다

 >  Q&A  >  본문

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>

黄舟黄舟2768일 전795

모든 응답(1)나는 대답할 것이다

  • 巴扎黑

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

    spring-context 패키지를 소개합니다

    회신하다
    0
  • 취소회신하다