The number of bean instances

Report a typo

Suppose we have an application with three components and one bean as shown below:

Java
@Component
class Component1 {
    private final MyBean bean;

    Component1(MyBean bean) {
        this.bean = bean;
    }
}

@Component
class Component2 {
    private final MyBean bean;

    Component2(MyBean bean) {
        this.bean = bean;
    }
}

@Component
class Component3 {

}

@Configuration
class Config {

    @Bean
    @Scope("prototype")
    public MyBean myBean(Component3 component3) {
        return new MyBean();
    }
}
Kotlin
@Component
class Component1(private val bean: MyBean)

@Component
class Component2(private val bean: MyBean)

@Component
class Component3

@Configuration
class Config {
    @Bean
    @Scope("prototype")
    fun myBean(component3: Component3): MyBean {
        return MyBean()
    }
}

How many instances of the MyBean and Component3 classes will we have in this situation?

Select one option from the list
___

Create a free account to access the full topic