There are no out-of-the-box artifacts for reading templates from a DB, but you can create your own by following these steps:
1st. Create an implementation of IResourceResolver [
http://www.thymeleaf.org/apidocs/thymeleaf/2.0.13/org/thymeleaf/resourceresolver/IResourceResolver.html ] that is able to load files from your database (can be templates, but could also be other things you might want to store at your DB like i18n files...).
2nd. Create an implementation of ITemplateResolver [
http://www.thymeleaf.org/apidocs/thymeleaf/2.0.13/org/thymeleaf/templateresolver/ITemplateResolver.html ] that uses this "resource resolver" you created for reading templates and, once your template is read, assigns it several metainformation like template mode, cache capabilities, etc. I recommend you to use "AbstractTemplateResolver" or maybe even "TemplateResolver" instead as a base for creating your extension.
Then simply add your now template resolver to your template engine and you are done :-)
As a plus, note that your ITemplateResolver implementation can return for each template an ITemplateResolutionValidity instance (see
http://www.thymeleaf.org/apidocs/thymeleaf/2.0.13/org/thymeleaf/templateresolver/ITemplateResolutionValidity.html ), which might allow you to implement some kind of intelligent cache invalidation policy able to avoid queries to database for retrieving templates for as long as they don't change in database (you could check for changes only every x minutes, for example), heavily improving your performance...
Regards,
Daniel.