I'm trying to find a way to use the Immutables library to create data classes for holding the configuration of my Spring Boot application.
My data configuration class is:
@Value.Immutable
@JsonDeserialize(as = ImmutableAuthConfig.class)
public interface AuthConfig {
String domain();
String clientId();
@Value.Redacted
String clientSecret();
}
While the main configuration class is set up as
@Configuration
@EnableConfigurationProperties
@ConfigurationProperties
public class Config {
private ImmutableAuthConfig auth;
public AuthConfig getAuth() {
return auth;
}
public void setAuth(ImmutableAuthConfig auth) {
this.auth = auth;
}
}
I've tried some variations of using either ImmutableAuthConfig
or just AuthConfig
as a field, but nothing improved the situation. The configuration did not get picked up, and the auth
field of the configuration remains null
after application start-up.
Replacing the contents of the AuthConfig
class with a traditional POJO solves the issue, but I would prefer an immutable object. Is there any way to convince Spring to interface with the classes generated by the Immutables library?
AuthConfig
class and what is it supposed to be storing? – Genome@JsonDeserialize
annotation. I'm looking for something similar for whatever technique Spring is using for its configuration files. – KokoschkaImmutables
is. I haven't used it myself and thus I do not know 100% how this integrates with Spring. My main question is on how theAuthConfig
values get generated. Are you reading them for a props file, are your retrieving them from a server? – Genome@ConfigurationProperties
? – Genome