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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
spring-context包引入一下吧