9

I'm experimenting with Spring Boot (1.1.9.RELEASE) and Apache Velocity (1.7) with the intention of using Velocity as a templating tool for generating emails. I'm using Thymeleaf (2.1.3.RELEASE) for web templates.

Spring Boot's Autoconfiguration detects Velocity on the classpath during start up and adds it as a web view resolver. While this is brilliant, it's not what I want so I tried

@EnableAutoConfiguration(exclude = {VelocityAutoConfiguration.class})
public class Application {

but I still ended up with a velocityViewResolver bean once the application had started up.

Any idea how I might go about disabling this automatic configuration?

Thanks in advance for any replies.

4
  • 1
    That should do it. If you want the velocity configuration but not the view resolver you can just define your own bean named "velocityViewResolver" (I'm pretty sure it says that in the user guide).
    – Dave Syer
    Commented Nov 26, 2014 at 13:03
  • I experienced something along the same lines with 1.1.9. In addition to the exclude I added spring.velocity.checkTemplateLocation=false and it seemed to stop complaining about not finding index.vm. This may have been addressed in 1.2 (RC) which I am testing now as I see the exclude does the trick on it's own.
    – hoserdude
    Commented Dec 2, 2014 at 5:07
  • Thanks both for confirming I wasn't barking up the wrong tree :) Commented Dec 8, 2014 at 12:53
  • Is it possible to disable only WebappResourceLoader ? I have a "regular" viewresolver for JSP's which works, and I need Velocity for emails, thus I only want to disable Velocity looking for web resources.
    – yglodt
    Commented Nov 4, 2015 at 15:20

1 Answer 1

9

With Spring Boot 1.2.5, disabling the autoconfiguration on the main application class seems to be enough:

@SpringBootApplication
@EnableAutoConfiguration(exclude = { VelocityAutoConfiguration.class })

Edit I don't exactly know since when that works, but now (Spring Boot 1.3.2) you can also set :

spring.velocity.enabled=false

in application.properties.

Not the answer you're looking for? Browse other questions tagged or ask your own question.