BAEL-2914: Immutable @ConfigurationProperties binding (#8623)
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ConfigurationPropertiesScan
|
||||
public class ImmutableConfigPropertiesApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ImmutableConfigPropertiesApp.class, args);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||
|
||||
@ConfigurationProperties(prefix = "mail.credentials")
|
||||
@ConstructorBinding
|
||||
public class ImmutableCredentials {
|
||||
|
||||
private final String authMethod;
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
public ImmutableCredentials(String authMethod, String username, String password) {
|
||||
this.authMethod = authMethod;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user