I have a config class which is creating the beans for my application. I am seeing that although I set the bean properties while creating adapter bean, somehow these properties are getting cleared and set to null in my controller class. After 2 hours of debugging, I am drawing a blank. Any pointers please.
@RequiredArgsConstructor//lombok annotation to generate the constructor.
public class MyAdapter {//Trying to create a bean of this type
@NonNull private final MyPropertyObj prop;
@NonNull private final Integer timeout;
}
@Configuration
@Profile("!test")
class MyConfigClass{
@Bean
public MyAdapter adapter(){
MyPropertyObj prop= new MyPropertyObj();
return new MyAdapter(prop, 10);//Here I am setting prop and 10, but when I check auto wired adapter they are null.
}
}
public class MyController {
@Autowired private MyAdapter adapter;
//adapter gets injected, but adapter.prop and the adapter.timeout are null.
}