In the Spring Roo reference documentation, we see that
web mvc templates
setup Includes view generation templates on current project. Will allow developers to customize view generation by modifying the templates from [PROJECT-ROOT]/.roo/templates/…
Once I modify the templates in .roo/templates/, how do I get those change reflected to the built out .html files that result from executing the command
web mvc controller --entity ~.model.MyObject --responseType THYMELEAF
? (EDIT 4 - I can't just run the above again as roo says ...'already exists')
I have tried
mvn clean package
and rerunning
mvn spring-boot:run
but the changes made in the .ftl files after they are generated never seem to be pushed into the output found in src\main\resources\templates. I assume there is a Roo Console command to run but the reference documentation seems to omit fully explaining this process.
EDIT
I've also tried adding the property
spring.thymeleaf.cache=false
but this didn't seem to help.
EDIT 2
I'm using the Roo CLI, not STS.
I am using a .roo file and the commands execute in the following order for this part of the process:
web mvc setup
web mvc view setup --type THYMELEAF
web mvc templates setup --type THYMELEAF
I am testing whether the order may be wrong here. (Update - nope, that's the correct order. view setup creates the output in the src directory, templates setup puts the .ftl files in the .roo directory. Just need to know how to trigger an update to the .html after editing the .ftl).
EDIT 3
I noticed in the freemarker documentation, which thymeleaf uses, that the config class is responsible for identifying the template loading functionality. When I looked in my generated code, I noticed the .aj files for the WebMvcConfiguration.java were not pushed in. I moved my .roo script push-in --all command to the end of my file and that took care of the errant .aj files. This doesn't seem to include a setDirectoryForTemplateLoading method or anything similar. It does create the following, which I plan to investigate further.
public TemplateEngine getTemplateEngine() {
return templateEngine;
}
@Bean
public ThymeleafViewResolver javascriptThymeleafViewResolver() {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(getTemplateEngine());
resolver.setCharacterEncoding("UTF-8");
resolver.setContentType("application/javascript");
resolver.setViewNames(new String[] { "*.js" });
resolver.setCache(getThymeleafProperties().isCache());
return resolver;
}
After these were added to the configuration I tried some edits to the .ftl files and both restarted the spring boot app and recompiled it. Neither resulted in the .ftl being processed to update the generated .html.
Still no resolution at the moment.
EDIT 5 (EDIT 4 is up above inline)
Playing around with the roo console now to see if I can figure this out. I learned that web mvc templates setup --type THYMELEAF overwrites any changes made to the .ftl files.