-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Better document new @AutoConfiguration annotation #35044
Comments
I've made some small updates, both to the 3.0 migration guide and to the 2.7 release notes. I think the existing reference documentation already covers quite a bit of this. For example, it explains that |
Yes, it explains that The documentation doesn't answer this questions:
What I want to see in the documentation (and not just migration guides) is something like this:
Why is that important: because we (the whole community) have millions of already written code, libraries, starters, that use The phrase "making auto-configurations standard Therefore, according to the current documentation, it looks like only |
Also I found this comment: eventuate-foundation/eventuate-common#130 (comment) So, now I really wonder if my conclusion that |
Those comments are incorrect and it will continue to work. I still don't think we should go into any more details in the documentation and my feeling is that it will overwhelm the reader with too much information. If you would really like to see a change, please propose something in a pull request and we will review it. Perhaps it won't look as bad as I suspect when we see it. |
Ok, thank you for the confirmation. I'm glad that it will work! But, see? This confuses people. Not only me. 😸 Because documentation doesn't explicitly says that I disagree about "too much information" because it is very important information that I as a reader was trying to find (unsucessfully) and was forced to read the source code and do experiments to understand how it works (and if it works at all). But the problem with experiments is that even if they confirm that it works, it doesn't mean that it is just a coincidence (an implementation details) and will be broken in the next release. On the other hand, if it is documented, then I could trust this behavior. Ok, I will try to do a pull request, thanks for the idea! I just usually hesitate to do PRs related to the docs because: a) I'm stull not 100% sure if this behavior is expected/intended (because it is NOT documented). |
After reading the documentation and javadocs for 3.0.x, it's still unclear what the difference between the new
@AutoConfiguration
annotation and old@Configuration
annotation.It's clear that
@AutoConfiguration
is meta-annotated with@Configuration(proxyBeanMethods = false)
. But the question is: was the only reason to have this new@AutoConfiguration
annotation is to promote "proxyBeanMethods = false
by default" rule? And probably also to mark a class for tooling.. Or there are some other reasons and consequences?I tried to search, but didn't found any discussions about motivation of introducing this annotation, except this #29870, but it's pretty undetailed.
Basically, will a class annotated with
@AutoConfiguration
annotation be 100% functionally equivalent to the same class, but directly annotated with@Configuration(proxyBeanMethods = false)
?What if a class, that is listed in the
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
file, will be annotated with@Configuration
annotation (contrary to documentation)? Will it still be found and properly registered in Spring Boot 3.x? Or will it be ignored?What if a class, that is annotated with
@AutoConfiguration
annotation will not be listed in theMETA-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
file, but instead will happen to be component-scanned? Will it be registered as a bean (because it is meta-annotated with@Configuration
) or will it be specifically filtered out to protect from accidental component-scanning of autoconfigurations? It would be very cool, if yes, or even better to not just filter-it-out, but to force the app startup to fail or at least print a warning, as this situation often leads to very subtle bugs.The migration guide also states that
@AutoConfiguration
should be used instead of@Configuration
for top-level autoconfiguration classes, but it doesn't explain what if someone doesn't follow this rule and still continues to use@Configuration
annotation on a top level autoconfiguration class? It's especially important for libraries (boot-starters) that want to be backward-compatible with both 2.x and 3.x.Probably, it's worth to mention in both migration-guide and official documentation that
@Configuration
will still work (if that is true) and also to slightly describe the motivation of introducing@AutoConfiguration
annotation. And, if some additional filters/logic/etc is applied only to@AutoConfiguration
-annotated classes, but not to@Configuration
-directly-annotated classes, then certainly to mention it too.Also, both documentation and migration guide doesn't describe what will happen in 2.7.x if both
spring.factories
andMETA-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
files are present and contain the same autoconfiguration class. It would be useful to have this setup for a library (a boot-starter) during migration period because this library could be used from:spring.factories
and new file will be read - here is the confusion);spring.factories
will be read).It would be possible only if 2.7.x somehow ignores one of 2 declarations. It would be useful to have a description of the behavior for this situation in the 2.7 migration guide (and probably 2.7.x docs).
The text was updated successfully, but these errors were encountered: