mustache-spring-view
mustache-spring-view copied to clipboard
Java based configuration
I posted a similar question to SO about java-based configuration: http://stackoverflow.com/questions/25311299/spring-java-based-config-resourceloader
Is this correct? I am getting a null pointer from a missing ResourceLoader.
@Configuration
@ComponentScan(basePackageClasses = Application.class, includeFilters = @Filter(Controller.class), useDefaultFilters = false)
class WebMvcConfig extends WebMvcConfigurationSupport {
@Bean
public MustacheViewResolver viewResolver() {
MustacheViewResolver resolver = new MustacheViewResolver();
resolver.setPrefix("/WEB-INF/views/mustache/");
resolver.setSuffix("hbs");
resolver.setCache(true);
resolver.setTemplateFactory(new MustacheJTemplateFactory());
return resolver;
}
}
In case anyone else has the same problem, I posted an answer to the StackOverflow question.
I think I see the problem. JMustacheTemplateLoader and MustacheJTemplateFactory both rely on the application context injecting the ResourceLoader via implementing ResourceLoaderAware.
I think there might be a few @Autowired missing.
@bsutherland's answer on SO is a good work around for now.
I'll see about getting this fixed.
Thanks sps!
I'm also having trouble with the i18n configuration using Java annotations. Here's what I have:
@Bean
public LocalizationMessageInterceptor getLocalizationMessageInterceptor() {
LocalizationMessageInterceptor lmi = new LocalizationMessageInterceptor();
lmi.setLocaleResolver(new FixedLocaleResolver(Locale.JAPAN));
lmi.setMessageSource(messageSource);
return lmi;
}
But my messages are not being resolved. Maybe related?