You are mixing things.
@Setter (and @Getter) are most likely lombok project annotations.
These annotations at compile time will generate the getX() and setX() methods on a Pojo with a property "x".
If the Credentials
POJO is in another jar, it should have a getter and setter (or it is not a POJO). So we don't care about lombok.
On another side you have a @Configuration
class where Spring boot will create the different beans of your application.
The class should look something like this:
@Configuration
@ConfigurationProperties("credentials")
public class MyCredentials {
@Bean("credentials")
public Credentials credentials(
@Value("${credentials.userid}") String userid,
@Value("${credentials.password}") String password) {
Credentials credentials = new Credentials();
credentials.setUserid(userid);
credentials.setPassword(password):
return credentials;
}
}
With the @Value annotation Spring boot will inject the properties into the method that will create the bean.
EDIT I
As stated by @M.Deinum, the same can be obtained by:
@Configuration
public class MyCredentials {
@Bean("credentials")
@ConfigurationProperties("credentials")
public Credentials credentials() {
return new Credentials();
}
}
@ConfigurationProperties will find the properties prefixed with "credentials" and inject them into the credentials bean.
Thanks for the tip @M.Deinum!