All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.welcome.ftl Maven / Gradle / Ivy

Go to download

This project contains a simple example demonstrating the usage of the Tamaya Spring module.

The newest version!





    

Tamaya - Spring Boot Example

This example shows how Tamaya Configuration can be used with Spring Boot to enable Spring with Tamaya dynamic configuration features and Tamaya Configuration Injection.

Accessing properties programmatically

Configuration properties can be easily accessed with Tamaya's Java API:
Configuration config = Configuration.current();
String value = config.get("foreground.color");
Hereby Tamaya also offers type safe access:
Color color = config.get("foreground.color", Color.class);

Annotating properties

Configuration properties on beans can be easily annotated with Tamaya.
  • You can use default Spring mechanism, e.g.:
    @Value("$\{application.message\:Hello World}")
    private String message = "Hello World";
    
  • You can use the Tamaya injection API, e.g.
    @Config(value = "background.color", required = false)
    private String backgroundColor = "#BBBBBB";
    
  • You can also use Tamaya's dynmic configuration features:
    @Config(value = "foreground.color", required = false, defaultValue = "#DDDDDD")
    private DynamicValue foregroundColor;
    
  • As with the programmatic API, type safe configuration is supported similarly:
    @Config(value = "background.color", required = false)<
    private Color bgColor = "#BBBBBB";
    

Demo: setting the foreground color

This small form allows you to set the foreground color of the following box. For simplicity it uses standard system property, but configuration could also be accessed from any kind of remote or local resource:


Foreground Color: ${foreground}
Background Color: ${background}

Date: ${time?date}
Time: ${time?time}
Message: ${message}

Configuration Data

You can access the current configuration using the following URL: /config.
Add additional path parameters for filtering...




© 2015 - 2025 Weber Informatics LLC | Privacy Policy