We use Spring Boot in our application along with AngularJS and HTML. We use Velocity only for email templates but not for view resolver.
@Bean(name = "velocityEngine")
public VelocityEngineFactoryBean velocityEngineFactoryBean() {
VelocityEngineFactoryBean vefb = new VelocityEngineFactoryBean();
Properties p = new Properties();
p.put("resource.loader", "class");
p.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
vefb.setVelocityProperties(p);
return vefb;
}
Even though we don't use Velocity view resolver, we get the following error due to auto-configuration:
ERROR org.apache.velocity - ResourceManager: unable to find a resource 'LoadList' in any resource loader. ERROR org.apache.velocity - ResourceManager: unable to find resource 'index' in any resource loader.
I tried to disable Velocity auto configuration:
@Configuration
@ComponentScan
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,VelocityAutoConfiguration.class })
@SuppressWarnings("PMD")
@EnableAsync
public class Application {
Also added the following in the application.properties file:
spring.velocity.check-template-location=false
But I'm still getting the above error. Is there any way to disable the Velocity view resolver alone?
Thymeleaf view resolver works by surrounding the view name with a prefix and suffix. The default values of prefix and suffix are 'classpath:/templates/' and '. html', respectively. Spring Boot also provides an option to change the default value of prefix and suffix by setting spring.
2) The InternalResourceViewResolver is also the default view resolver of DispatcherServlet class, which acts as the front controller in the Spring MVC framework.
An abstract view resolver which takes care of caching views. Often views need preparation before they can be used, extending this view resolver provides caching of views. An implementation of ViewResolver that accepts a configuration file written in XML with the same DTD as Spring's XML bean factories.
Spring MVC is a Web MVC Framework for building web applications. In generic all MVC frameworks provide a way of working with views. Spring does that via the ViewResolvers, which enables you to render models in the browser without tying the implementation to specific view technology.
I know this question is quite old, but it is quite easy to disable:
just add
spring.velocity.enabled = false
to the application.properties
Source: http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
In Spring boot, With Annotation, you can exclude the VelocityAutoConfiguration like
@SpringBootApplication
@EnableAutoConfiguration(exclude = {VelocityAutoConfiguration.class})
@EnableGlobalMethodSecurity(securedEnabled = true)
public class Application extends SpringBootServletInitializer {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With