I have a simple SpringBoot 2.3.5 application with spring-cloud-starter-aws-messaging starter added. I have some configuration class as follows:
@Configuration
public class AppConfig {
@Autowired
private Environment env;
@Bean
public AmazonS3 amazonS3() {
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
builder.enablePathStyleAccess();
AmazonS3 amazonS3 = builder.build();
return amazonS3;
}
}
Now when I run the application the @Autowired environment is null. If I rename the bean registration method from amazonS3 to anything say amazonS3Bean then environment bean is properly initialised and is not null.
Why amazonS3 name is so special and why it is making environment bean as NULL?