✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Was wird ausgegeben, wenn man die Anwendung startet: [EK]
@Scope("prototype")
@Component
public class GreeterPrototype{
private static int lastId = 0
;
private final int id = ++lastId
;
@Override
public String toString() {
return "GreeterPrototype " + id
;
}
}
@Component
public class ProfileTester implements CommandLineRunner{
@Autowired
private GreeterPrototype greeterPrototype
;
@Autowired
private ApplicationContext context
;
@Override
public void run(String... args) throws Exception{
System.out.println(greeterPrototype + "\n" + context.getBean(GreeterPrototype.class
));
}
}