Disabling Pebble cache with Spring Boot

317 views
Skip to first unread message

Martin

unread,
Apr 25, 2016, 1:36:18 PM4/25/16
to Pebble Templating Engine
Hi,

I'm evaluating Pebble as a potential replacement for standard JSP templates.  So far so good, but
pebble.cache=false doesn't seem to disable the cache as described here.  The value gets set properly in PebbleAutoConfiguration but it looks like it has no effect.  I have to restart my app on every single modification I make to my templates.

Anyone can help me with that?

Thank you!


Message has been deleted

Jochen Pier

unread,
Apr 29, 2016, 6:18:34 PM4/29/16
to Pebble Templating Engine
I had exactly the same problem. I found this workaround:

Define in your config a PebbleEngine Bean yourself. 

Example:

@SpringBootApplication


public class DemoPebbleApplication {

       public static void main(String[] args) {

               SpringApplication.run(DemoPebbleApplication.class, args);

       }

       @Bean

        public PebbleEngine pebbleEngine() {

                return new PebbleEngine.Builder().cacheActive(false).

                               build();

       }

}



Martin

unread,
May 10, 2016, 11:58:54 AM5/10/16
to Pebble Templating Engine

Thanks for your reply Jochen.

I basically ended up doing the same thing.  Except that I binded it to a new configuration Properties.

@Configuration
public class PebbleTemplateConfiguration {

   
@Autowired
   
TemplateProperties templateProperties;

   
@Bean
   
public PebbleEngine pebbleEngine() {
       
return new PebbleEngine.Builder().cacheActive(templateProperties.isCached()).build();
   
}

}

@ConfigurationProperties(prefix = "spring.template")
public class TemplateProperties {

   
private boolean isCached = true;

   
public boolean isCached() {
       
return isCached;
   
}

   
public void setCached(boolean isCached) {
       
this.isCached = isCached;
   
}
}



Jochen Pier

unread,
Jul 8, 2016, 12:12:45 PM7/8/16
to Pebble Templating Engine
The newest version (2.2.2) is handling this correctly! So just update... 

Batuhan Çağlayan

unread,
Oct 3, 2017, 3:04:20 AM10/3/17
to Pebble Templating Engine
Hello,

I ama trying to implement a mvc project (with spring boot). I added **pebble-spring-boot-starter** dependency to pom.  I set suffix as .twig in ViewResolver method. But template engine check .pebble files under templates/ path. In debug, i see pebbleatuoconfiguration class set default suffix and prefix values lastly. How can i stop this process.

Please help,
Batuhan Çağlayan

Batuhan Çağlayan

unread,
Oct 3, 2017, 3:44:17 AM10/3/17
to Pebble Templating Engine
Ok
boot load @ConfigurationProperties("pebble")  (PebbleProperties class), 

pebble.prefix:templates/
pebble.suffix:.twig
pebble.cache:false
pebble.encoding:UTF-8

added to application.properties file issue solved.

Thanks.
Reply all
Reply to author
Forward
0 new messages