Let me clarify my current practice. I have a maven project and the package architecture looks like below:
src/main/java/com/gearon/app/App.java
src/main/java/com/gearon/app/configuration/Config.java
src/main/java/com/gearon/app/datamodel/*.java
I tried to set directory where to load templates in Config.java with code below:
cfg = new Configuration();
cfg.setClassForTemplateLoading(Config.class, "/templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
I have put templates under src/main/java/com/gearon/app/templates
The architecture is src/main/java/com/gearon/app/templates/*.ftl
It works fine if I run the code directly with main method. However, when I package the project into a jar, it fails to load templates and the error looks like below:
java.io.FileNotFoundException: Template "index.ftl" not found.
I'd like to know where to put those tempaltes.