VelocityEngine Spring Java Config


Dev-Bookmarks Logo

Save up to a workweek a year by efficiently managing your dev bookmarks, on www.bookmarks.dev. Share your favorites with the community and they will be published on Github - Star


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?

Lots of exciting dev bookmarks added in march 2019

Lots of exciting dev #bookmarks added in march 2019. Keywords: alias, api, api-management, architecture, arquillian, async, asynchronous, awesome, awesome-list, aws, bash, bootstrap, c, chai, cheatsheet, circuit-breaker, css, devops, diagnostics, diagram, dns, docker, docker-compose, docs, documentation, domain-driven-design, dotfiles, email, error-handling, facebook, favicon, ffmpeg, free-programming-books, functional-programming, gif, git, gradle, graph, helm, homebrew, html, html5, immutable.js, install, integration-testing, istio, java, javascript, jenv, junit, jvm, kotlin, kubernetes, kubernetes-helm, latex, linux, macos, markdown, maven-plugin, microservices, middleware, mocha, mongodb, monitoring, nginx, nodejs, oidc, online-tools, open-source, openid-connect, osx, package-manager, pandoc, performance, podcast, promise, proxy, r, reactive, reactive-programming, reactjs, redis, resources, rest, rxjs, security, shell, spring, spring-boot, spring-cloud, spring-cloud-gateway, spring-security, spring-webflux, sql, testing, tools, user-experience, video-processing, vim, visualization, web, websocket, windows and zuul Continue reading