Wednesday 15 February 2012

java - Accessing properties file in Spring Expression Language -



java - Accessing properties file in Spring Expression Language -

i created simple web application thymeleaf using spring boot. utilize application.properties file configuration. i'd add together new properties such name , version file , access values thymeleaf.

i have been able accomplish creating new javaconfiguration class , exposing spring bean:

@configuration public class applicationconfiguration { @value("${name}") private string name; @bean public string name() { homecoming name; } }

i can display in template using thymeleaf so:

<span th:text="${@name}"></span>

this seems overly verbose , complicated me. more elegant way of achieving this?

if possible, i'd avoid using xml configuration.

you can via environment. e.g.:

${@environment.getproperty('name')}

java spring spring-boot thymeleaf

No comments:

Post a Comment