ACV
ACV

Reputation: 10560

Spring Boot external configuration in Groovy

How to get Spring boot to load external properties for Groovy? Need something similar to java mechanism (application.properties in resources and ConfigBean with @Value annotations)?

When trying to use the same mechanism as with java, I don't know how to annotate the ConfigBean

@Component
public class ConfigBean {
    @Value("${seleniumAddress}")
    private String seleniumAddress; ...

and then in application.properties

seleniumAddress=http://localhost:4444/wd/hub

but with groovy I cannot annotate the field with @Value("${seleniumAddress}" It throws an error complaining about "${}" - this is a special sequence in groovy. So what mechanism should I use here?

Thank you

Upvotes: 4

Views: 2259

Answers (1)

Dave Syer
Dave Syer

Reputation: 58144

If you use "${}" for Spring placeholders in Groovy you have to make sure it's a String (not a GString): i.e. use '${}' (single quotes).

Upvotes: 14

Related Questions