spring 4.1.6.RELEASE maven
error:
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
的xml:
<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="/"/>
<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"/>
<property name="dateToolAttribute" value="dateTool"/>
<!-- velocity toolbox -->
<property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
</bean>
答案 0 :(得分:0)
java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory
表示jar不可用于加载上下文。
<!-- http://mvnrepository.com/artifact/org.apache.velocity/velocity -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.velocity/velocity-tools -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>
请确保添加了这些依赖项。
同样需要vm
个文件应该在类路径中加载和执行。