7

I have a Spring Boot 2.1.0.RELEASE project. How can I see the thymeleaf version it uses?

Zoe
  • 27,060
  • 21
  • 118
  • 148
e-info128
  • 3,727
  • 10
  • 40
  • 57

3 Answers3

5

If you're using Maven, you can use list goal of maven dependency plugin:

$ mvn dependency:list -DincludeArtifactIds=thymeleaf

Or with Maven Wrapper:

$ ./mvnw dependency:list -DincludeArtifactIds=thymeleaf

Example output for maven:

[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ site ---
[INFO] 
[INFO] The following files have been resolved:
[INFO]    org.thymeleaf:thymeleaf:jar:3.0.9.RELEASE:compile

For Gradle:

$ gradle dependencyInsight --dependency org.thymeleaf:thymeleaf

With Wrapper:

$ ./gradlew dependencyInsight --dependency org.thymeleaf:thymeleaf

Example output for Gradle:

org.thymeleaf:thymeleaf:2.1.6.RELEASE (selected by rule)
\--- org.thymeleaf:thymeleaf-spring4:2.1.6.RELEASE
     \--- org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE
          \--- compile

org.thymeleaf:thymeleaf:2.1.4.RELEASE -> 2.1.6.RELEASE
\--- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:1.4.0
     \--- org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE
          \--- compile

org.thymeleaf:thymeleaf-spring4:2.1.6.RELEASE (selected by rule)
\--- org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE
     \--- compile

See also Inspecting dependencies

Dmitriy Popov
  • 2,150
  • 3
  • 25
  • 34
Denis Zavedeev
  • 7,627
  • 4
  • 32
  • 53
  • Ohhhh thanks :D `The following files have been resolved: org.thymeleaf:thymeleaf:jar:3.0.11.RELEASE:compile` – e-info128 Nov 07 '18 at 19:06
2

If you are using IntelIJ, a nice and simple solution is to click on Maven Projects (on the right) and expand the dependencies. enter image description here

Adina Rolea
  • 2,031
  • 1
  • 7
  • 16
1

According to Spring Docs, you can easily do this with your application properties file.

You can automatically expand properties from the Maven project using resource filtering. If you use the spring-boot-starter-parent you can then refer to your Maven ‘project properties’ via @..@ placeholders

Maven pom.xml:

<groupId>com.poo</groupId>
    <artifactId>gar</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

<name>Poo</name>
<description>Gar</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.4.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

Spring application.properties:

poo.app.version=@project.version@
  1. Then a class annotated with @ControllerAdvice can be used to inject version as model attribute.

     @ControllerAdvice 
     public class ControllerAdvice {
    
    @Value("${poo.app.version}")
    private String applicationVersion;
    
    @ModelAttribute("applicationVersion")
    public String getApplicationVersion() {
        return applicationVersion;
    }}
    
  2. Finally this model attribute can be accessed by Thymeleaf as any other. With a th:text tag, try to access the model attribute below so you can display what version of Thymeleaf your app is using:

    ${applicationVersion}

Zeusox
  • 7,708
  • 10
  • 31
  • 60
  • 2
    Thanks, need only see thymeleaf version, the sintaxis of 2.x and 3.x are difference, need see is 2 or 3. pom.xml: `spring-boot-starter-thymeleaf` have not the version. – e-info128 Nov 05 '18 at 16:45