What is the difference between using @Autowired or @PostConstruct on a method since they offer the same result (according to what I have understood from different sources)
UPDATE: Here is an example of my class in which I get the same result if I use @Autowired or @PostCosntruct to annotate the method configClient()
@Service
public class AwsSTSService {
@Autowired
private AwsConfiguration awsConfiguration;
public CustomCredentials getCredentials() {
......
return customCredentials;
}
@Autowired // or @PostConstruct
private void configClient() {
CustomCredentials customCredentials = getCredentials();
awsConfiguration.setAwsAccessKey(customCredentials.getAccessKeyId());
awsConfiguration.setAwsSecretKey(customCredentials.getSecretAccessKey());
awsConfiguration.setExpiration(customCredentials.getExpiration());
awsConfiguration.setSessionToken(customCredentials.getSessionToken());
}
}