Skip to content

andrehertwig/spring-boot-starter-velocity2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring-Boot auto configuration for Velocity 2.0 Template Engine

Just a Spring-Boot starter for Velocity 2.0 Template Engine.

This starter just appends the Velocity Engine 2.0 to Spring context and you can configure it via spring properties. Because Velocity-Tools is still in version 2.0 and incompatible to Velocity-Template-Engine 2.0 there is no implmentation for tools. Furthermore this starter does not provide any ViewResolver.

Maven Central GitHub issues license

This is just a spare-time project. The usage of this tool (especially in production systems) is at your own risk.

Content

  1. Requirements, Dependencies
  2. Usage
  3. Configuration Properties
  4. Additional Things

Requirements, Dependencies

  • spring-boot
  • apache velocity 2.0
  • apache velocity tools 3.0 (optional)

Unit-Tested with Spring Boot 1.5.6, 1.5.19

Usage

<dependency>
	<groupId>de.chandre.velocity2</groupId>
	<artifactId>spring-boot-starter-velocity2</artifactId>
	<version>1.1.0</version>
</dependency>
	

Maybe you have to explicitly enable the component scan for the package:

@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan(basePackages={"your.packages", "de.chandre.velocity2.spring"})
public class MyBootApplication {
 
}

Configuration Properties

For special configuration, please check the additional-spring-configuration-metadata.json

Additional Things

If you want to add velocity properties at runtime while application start-up, you are able to do that by implementing the de.chandre.velocity2.spring.Velocity2PropertiesOverrideHook.

Example:

@Configuration
@AutoConfigureBefore(Velocity2AutoConfiguration.class)
public class VelocityConfig
{
	private static final Logger LOGGER = LogManager.getFormatterLogger(VelocityConfig.class);
	
	@Bean
	public Velocity2PropertiesOverrideHook velocity2PropertiesOverrideHook(MyResourceManager rcMgr) {
		return new Velocity2PropertiesOverrideHook() {

			@Override
			public Properties override(Properties velocityProperties) {
				velocityProperties.put(RuntimeConstants.RESOURCE_MANAGER_INSTANCE, rcMgr);
				return velocityProperties;
			}
		};
	}
}

About

Spring-Boot auto configuration for Velocity 2.0 Template Engine

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages