-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Java based config should support class-only component declarations through @Import [SPR-11740] #16362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Luiggi Mendoza commented This would be hard to accomplish. What would happen if instead <pre>MyFunkySpringBean</pre> you have <pre>Long</pre> or <pre>String</pre> classes or an immutable class that requires specific arguments? |
Marty Pitt commented I don't see how rejecting that as invalid is any harder than rejecting the analogous XML as invalid: <bean class ='Java.lang.long" I'd="invalid" /> Ultimately, I'd expect these two syntaxes are the same. Sent from my phone.... Apologies for any typos. |
cemo koc commented In that case:
|
Marty Pitt commented Would expect that if a This has different semantics than a declared annotated field which provides no value, only a type. Ultimately, the syntax itself I'm not too fussed on... Only a means of saying to the spring container: "Hey... I want one of these, and I want you to build it, best as you can". This is what the XML equivalent says. |
Juergen Hoeller commented We have a related feature issue: #15547... It originated in a discussion about support for Our plate for Spring Framework 4.1 is pretty full at this point, with an RC1 planned in June and a GA target in July, so I can't make any promises about this idea being considered for it still. However, it's certainly a key feature candidate for Spring Framework 4.2, scheduled for Q1 2015. Juergen |
Juergen Hoeller commented
A dedicated Juergen |
Juergen Hoeller commented I've relaxed our This is a very straightforward change and from my perspective at the right side of the 80/20 tradeoff. Given the ease of allowing for this, I am not in favor of adding field-based declarations for the same purpose. Abstract methods would have the additional benefit of allowing for cross-method calls like with regular Juergen |
Steven Schlansker commented It would be nice if this feature was documented, I had to find this from a link on Stack Overflow and it's a pretty nice feature! |
Marty Pitt opened SPR-11740 and commented
Currently, when declaring my beans via Java config, I'm provided with two options:
@Component
annotation, and let Spring discover the bean.@Bean
annotation within a@Configuration
class.There is a valid use case where I would like to explicitly declare a set of beans, but leave Spring responsible for their construction.
This is analogous to the classic
<bean class="">
xml approach.A possible syntax for this would be:
Reference URL: http://stackoverflow.com/questions/23313262/spring-java-config-specify-class-only
Issue Links:
@Bean
on Java 8 default methods in interfacesReferenced from: commits f0ac278, a15dc08
1 votes, 9 watchers
The text was updated successfully, but these errors were encountered: