Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring5.0.1 VelocityEngineFactoryBean

Tags:

spring

Multiple annotations found at this line: - Class 'org.springframework.ui.velocity.VelocityEngineFactoryBean' not found - Class 'org.springframework.ui.velocity.VelocityEngineFactoryBean' not found [config set: MyApp/web- context]

    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
  <property name="velocityProperties">
     <value>
      resource.loader=class
      class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
     </value>
  </property>
</bean>
like image 672
Srinu Babu Avatar asked Feb 05 '18 16:02

Srinu Babu


2 Answers

Spring has marked Velocity package org.springframework.ui.velocity as deprecated in Spring 4.3 and removed it completely in Spring 5.0.1 (according to Jürgen Höller, it's because Velocity Framework "dates back to 2010").
Source: https://jira.spring.io/browse/SPR-13795.

However, you can still use Velocity 1.7 in Spring 5.0.x Framework.
Just follow the answer of @bekce in this thread.

like image 172
Itzik Shachar Avatar answered Sep 20 '22 18:09

Itzik Shachar


As it was mentioned on VelocityEngineUtils has been removed in Spring 3.2 so what else to use? you need to have Velocity dependency:

<dependency>
    <groupId>org.apache.velocity</groupId>
    <artifactId>velocity</artifactId>
    <version>1.7</version>
</dependency>

For XML configs, replace deprecated VelocityEngineFactoryBean with VelocityEngine:

<util:properties id="velocityProperties">
  <prop key="resource.loader">class</prop>
  <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop>
</util:properties>

<bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
  <constructor-arg ref="velocityProperties">
</bean>
like image 22
Justinas Jakavonis Avatar answered Sep 21 '22 18:09

Justinas Jakavonis