I created a simple web application with Thymeleaf using Spring Boot. I use the application.properties file as a configuration. I would like to add new properties, such as name and version, to this file and access the values ββfrom Thymeleaf.
I was able to achieve this by creating a new JavaConfiguration class and exposing the Spring Bean:
@Configuration public class ApplicationConfiguration { @Value("${name}") private String name; @Bean public String name() { return name; } }
Then I can display it in the template using Thymeleaf:
<span th:text="${@name}"></span>
It seems too verbose and complicated for me. What would be a more elegant way to achieve this?
If possible, I would like to avoid using the xml configuration.
source share