Thymeleaf Hello World – day 1 – Project Structure

Developing application using Spring boot and Thymeleaf is simpler and quick, if you follow these convention. Thymeleaf requires a specific project structure which helps to render views and refer items without getting into error.

Since we are using Spring Boot, because we’ve included the dependency springbootstarterthymeleaf in our Maven POM for the project, so Spring Boot will do some things automatically for us.


By default, Spring Boot configures the Thymeleaf template engine to read template files from src/main/resources/templates .

Effectively, you as the developer just need to start making Thymeleaf templates and dropping them into  src/main/resources/templates.

Static Resources

It includes libraries and their respective javascript (*.js) and stylesheets (*.css) files to be placed inside src/main/resources/static


Project Structure/Convention

  • Messages to placed inside src/main/resources/messages into the
  • It requires static web content to be placed inside src/main/resources/static (this will be the root directory for your web application for static content like images, CSS and JavaScript files)
  • Most importantly templates must go into src/main/resources/templates and if required, subdirectories there.

Be clean on configuration

  • Use src/main/resources/ as few as possible
  • Use src/main/resources/applicationContext.xml as few as possible
  • Try to use annotation-based configuration as much as possible

All those points are very important, if you don’t follow them, you will get into trouble when you try to run your application standalone and not from your IDE!

Reference :


Tagged: , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: