VelocityEngine Spring Java Config

This is a first post in a series of short code snippets that will present the configuration of Spring beans from XML to Java.

XML:

<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>

Java:

@Bean
public VelocityEngine velocityEngine() throws VelocityException, IOException{
	VelocityEngineFactoryBean factory = new VelocityEngineFactoryBean();
	Properties props = new Properties();
	props.put("resource.loader", "class");
	props.put("class.resource.loader.class",
			  "org.apache.velocity.runtime.resource.loader." +
			  "ClasspathResourceLoader");
	factory.setVelocityProperties(props);

	return factory.createVelocityEngine();
}
Podcastpedia image

Adrian Matei

Creator of Podcastpedia.org and Codingpedia.org, computer science engineer, husband, father, curious and passionate about science, computers, software, education, economics, social equity, philosophy - but these are just outside labels and not that important, deep inside we are all just consciousness, right?

How to get the title of a remote web page using javascript and NodeJS

This post presents how to use web scraping with Cheerio in a NodeJS backend to retrieve the title of a bookmark added in bookmarks.codingpedia.org Continue reading

How to use Showdown in Angular and NodeJS

Published on February 21, 2017

Sharing coding bookmarks

Published on February 11, 2017