micronaut-core
micronaut-core copied to clipboard
Consider aligning default scope for @Bean when you use it to mark a class or via a factory
This would be @Prototype
scope:
@Bean
class Robot {
}
however, the following code defaults to@Singleton
:
@Factory
class RobotFactor {
@Bean
Robot create() {
return new Robot();
}
}
I think it would be less confusing to have them both default to the same scope. Maybe,
@Bean
class Robot {
}
should be a @Singleton
in Micronaut 4?
We also need to define what annotations are inherited to the bean from the factory method and class.
it is a bug that the factory version defaults to singleton IMO
The factory class itself is a singleton, which looks correct to me. What are prototypes are the beans created by it