Random template not found with Freemarker

2019-08-28 01:08发布

问题:

I'm using FreeMarker with a Play 2.3.8 app. When I execute my tests, sometimes I get the following error :

Caused by: java.io.FileNotFoundException: Template "MyTemplate.tpl" not found. The quoted name was interpreted by this template loader: ClassTemplateLoader(baseClass=com.project.TemplateEngineConfigurer, packagePath="templates/").

MyTemplate.tpl is in com.project.templates package and I'm using the following configuration :

    Configuration config = new Configuration(Configuration.getVersion());
    config.setClassForTemplateLoading(getClass(), "templates");
    config.setDefaultEncoding("UTF-8");
    config.setCacheStorage(new MruCacheStorage(20, 250));
    return config;

I can't understand why I have randomly, file not found exception... Is it an Eclipse problem ? A cache problem ?

Thanks.