Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java based configuration #18

Open
samspot opened this issue Aug 14, 2014 · 3 comments
Open

Java based configuration #18

samspot opened this issue Aug 14, 2014 · 3 comments

Comments

@samspot
Copy link

samspot commented Aug 14, 2014

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;
    }
}
@ghost
Copy link

ghost commented Sep 25, 2014

In case anyone else has the same problem, I posted an answer to the StackOverflow question.

@sps
Copy link
Owner

sps commented Sep 25, 2014

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.

@ghost
Copy link

ghost commented Sep 26, 2014

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants