java - springmvc 和velocity 配置 报错NoClassDefFoundError
黄舟
黄舟 2017-04-17 17:29:36
0
1
827

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>

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

모든 응답(1)
巴扎黑

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

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿