@Service
public class EmailService{
VelocityEngine velocityEngine;
@Bean
public VelocityEngine getVelocityEngine() throws VelocityException, IOException {
VelocityEngineFactory factory = new VelocityEngineFactory();
Properties props = new Properties();
props.put("resource.loader", "class");
props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
props.put("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
factory.setVelocityProperties(props);
return factory.createVelocityEngine();
}
}
applicationContext.xml
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="resourceLoaderPath" value="${velocity.resourceLoader.path}" />
</bean>
applicationContext.properties
velocity.resourceLoader.path=C:\\Users\\Dev\\Git\\MyProject\\resources\\WEB-INF\\velocity
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'voucherSummary_mail.vm'
How do I get
VelocityEngine
without thegetVelocityEngine()
method?How do I make
VelocityEngine
get the template file from the folder that I set in applicationContext?