IntelliJ IDEA 2021.1 Help

Thymeleaf

IntelliJ IDEA supports the Thymeleaf latest release version.

Overview of Thymeleaf support

Thymeleaf support in IntelliJ IDEA includes:

  • Code completion for expressions and th:* attributes.

    Thymeleaf completion

  • The Navigate to Declaration feature (Navigate | Declaration or Ctrl+B) that lets you jump from a reference in a template to the corresponding getter method, message in a .properties file or other appropriate code fragment.

    Thymeleaf navigate to declaration

  • The Navigate to Type Declaration feature (Navigate | Type Declaration or Ctrl+Shift+B) for switching to corresponding type definitions.

    Thymeleaf navigate to type declaration

  • The Rename refactoring (Refactor | Rename or Shift+F6) for referenced properties (and getter methods), iteration and status variables, etc.

  • Code inspections that find unresolved references and errors in expression syntax.

    Thymeleaf code inspections

  • Various Find functions e.g. Find Usages (Edit | Find | Find Usages or Alt+F7 ).

  • Intention actions such as Create property for unresolved message references or Import class for adding the import statements for org.thymeleaf.* classes.

    Thymeleaf intention actions

  • Preview in a web browser for your prototypes (the static part of your templates) that can be accessed right from the editor.

    Thymeleaf view in browser

Enabling the Thymeleaf plugin

To be able to use the Thymeleaf support in IntelliJ IDEA, make sure that the Thymeleaf plugin is enabled. (This plugin is bundled with the IDE and enabled by default.)

See Manage plugins.

Thymeleaf support for projects and modules

You can add Thymeleaf support when creating a project or module, or for an existing project or module. In all such cases, IntelliJ IDEA downloads the Thymeleaf library files (you can select which of the library files are necessary and which aren't) and adds them to the dependencies of the corresponding module.

You can also create a "Thymeleaf project" by opening an appropriate pom.xml file. In that case, the dependencies in your project will be managed by Maven. For more info, see Maven.

Adding Thymeleaf support when creating a project or module

  1. Do one of the following:

    • If you are going to create a new project: click Create New Project on the Welcome screen or select File | New | Project.

      As a result, the New Project wizard opens.

    • If you are going to add a module to an existing project: open the project you want to add a module to, and select File | New | Module.

      As a result, the New Module wizard opens.

  2. On the first page of the wizard, in the left-hand pane, select Java. In the right-hand part of the page, specify the JDK that you are going to use.

  3. Under Additional Libraries and Frameworks, select the Thymeleaf checkbox.

    In the lower part of the page, click Configure and select the library files that you want to download in the dialog that opens.

  4. You may also want to enable web app development support by selecting the Web Application checkbox. (For more info, see e.g. Enable Web application support .)

    Click Next.

  5. Specify the name and location settings.

    Click Finish.

Adding Thymeleaf support for an existing project or module

  1. Open the Project tool window (e.g. View | Tool Windows | Project ).

  2. Right-click the project or the module folder and select Add Framework Support.

  3. In the left-hand pane of the Add Frameworks Support dialog that opens, select the Thymeleaf checkbox.

  4. In the right-hand part of the dialog, click Configure and select the library files that you want to download in the dialog that opens.

  5. You may also want to enable web app development support by selecting the Web Application checkbox. (For more info, see e.g. Enable Web application support .)

  6. Click OK in the Add Frameworks Support dialog.

Last modified: 08 March 2021