DEV Community

mani-playground
mani-playground

Posted on

3 2

Spring boot properties file tips

Setting a variable with the value of a property from .properties file (note how spring does automatic type conversion to int)

    @Value("${some.property}")
    private int SOME_PROPERTY;
Enter fullscreen mode Exit fullscreen mode

Use a default property value if the specified property is not present

    @Value("#{'${prop.val.specific:${prop.val.default:}}'}")
    private String PROP_VALUE;
Enter fullscreen mode Exit fullscreen mode

Setting comma separated values to a List

    @Value("#{'${comma.separated.property}'.split(',')}")
    private List<String> COMMA_SEPARATED_PROPERTY;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay