@Bean public VelocityConfigurer velocityConfig() { VelocityConfigurer velocityConfigurer = new VelocityConfigurer(); velocityConfigurer.setResourceLoaderPath("/WEB-INF/velocity/"); return velocityConfigurer; }
/** * Initialize VelocityEngineFactory's VelocityEngine * if not overridden by a pre-configured VelocityEngine. * @see #createVelocityEngine * @see #setVelocityEngine */ @Override public void afterPropertiesSet() throws IOException, VelocityException { if (this.velocityEngine == null) { this.velocityEngine = createVelocityEngine(); } }
@Override protected void postProcessVelocityEngine(VelocityEngine velocityEngine) { super.postProcessVelocityEngine(velocityEngine); velocityEngine.setProperty(ROSE_MACRO_RESOURCE_LOADER_CLASS, ClasspathResourceLoader.class .getName()); velocityEngine.addProperty(VelocityEngine.RESOURCE_LOADER, ROSE_MACRO_RESOURCE_LOADER_NAME); velocityEngine.addProperty(VelocityEngine.VM_LIBRARY, ROSE_MACRO_LIBRARY); if (logger.isInfoEnabled()) { logger.info("ClasspathResourceLoader with name '" + ROSE_MACRO_RESOURCE_LOADER_NAME + "' added to configured VelocityEngine"); } } }
@Bean public VelocityConfig velocityConfig() throws IOException, VelocityException { Properties config = new Properties(); config.setProperty("input.encoding", "UTF-8"); config.setProperty("output.encoding", "UTF-8"); config.setProperty("default.contentType", "text/html;charset=UTF-8"); config.setProperty("resource.loader", "class"); config.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); VelocityConfigurer velocityConfigurer = new VelocityConfigurer(); velocityConfigurer.setVelocityProperties(config); velocityConfigurer.afterPropertiesSet(); return velocityConfigurer; }
VelocityConfigurer cfg = new VelocityConfigurer(); cfg.setResourceLoader(resourceLoader); cfg.setResourceLoaderPath("classpath:/templates/") return cfg;
@Bean VelocityConfigurer velocityConfig() { return new VelocityConfigurer(); }
@Bean public VelocityEngine velocityEngine(VelocityConfigurer configurer) throws VelocityException, IOException { return configurer.getVelocityEngine(); }
@Bean @ConditionalOnMissingBean(VelocityConfig.class) public VelocityConfigurer velocityConfigurer() { VelocityConfigurer configurer = new VelocityConfigurer(); applyProperties(configurer); return configurer; }
@Bean public VelocityEngine velocityEngine(VelocityConfigurer configurer) throws VelocityException, IOException { return configurer.getVelocityEngine(); }
@Bean public VelocityConfigurer velocityConfig() { VelocityConfigurer velocityConfigurer = new VelocityConfigurer(); velocityConfigurer.setResourceLoaderPath("/WEB-INF/views/"); return velocityConfigurer; } }
@Bean @ConditionalOnMissingBean(VelocityConfig.class) public VelocityConfigurer velocityConfigurer() { VelocityConfigurer configurer = new VelocityConfigurer(); applyProperties(configurer); return configurer; }
@Override protected void postProcessVelocityEngine(VelocityEngine velocityEngine) { super.postProcessVelocityEngine(velocityEngine); velocityEngine.setProperty(ROSE_MACRO_RESOURCE_LOADER_CLASS, ClasspathResourceLoader.class .getName()); velocityEngine.addProperty(VelocityEngine.RESOURCE_LOADER, ROSE_MACRO_RESOURCE_LOADER_NAME); velocityEngine.addProperty(VelocityEngine.VM_LIBRARY, ROSE_MACRO_LIBRARY); if (logger.isInfoEnabled()) { logger.info("ClasspathResourceLoader with name '" + ROSE_MACRO_RESOURCE_LOADER_NAME + "' added to configured VelocityEngine"); } } }
/** * Initialize VelocityEngineFactory's VelocityEngine * if not overridden by a pre-configured VelocityEngine. * @see #createVelocityEngine * @see #setVelocityEngine */ @Override public void afterPropertiesSet() throws IOException { if (this.velocityEngine == null) { this.velocityEngine = createVelocityEngine(); } }
super.postProcessVelocityEngine(velocityEngine);
/** * Initialize VelocityEngineFactory's VelocityEngine * if not overridden by a pre-configured VelocityEngine. * @see #createVelocityEngine * @see #setVelocityEngine */ @Override public void afterPropertiesSet() throws IOException, VelocityException { if (this.velocityEngine == null) { this.velocityEngine = createVelocityEngine(); } }