Browse Source

Documentation updates around configuration classes

(cherry picked from commit efb5f17)
pull/1155/head
Juergen Hoeller 10 years ago
parent
commit
1bde1ff263
  1. 20
      src/asciidoc/core-beans.adoc

20
src/asciidoc/core-beans.adoc

@ -2907,7 +2907,6 @@ to perform certain actions upon initialization and destruction of your beans. @@ -2907,7 +2907,6 @@ to perform certain actions upon initialization and destruction of your beans.
[TIP]
====
The JSR-250 `@PostConstruct` and `@PreDestroy` annotations are generally considered best
practice for receiving lifecycle callbacks in a modern Spring application. Using these
annotations means that your beans are not coupled to Spring specific interfaces. For
@ -6622,13 +6621,16 @@ The behavior could be different according to the scope of your bean. We are talk @@ -6622,13 +6621,16 @@ The behavior could be different according to the scope of your bean. We are talk
about singletons here.
====
[NOTE]
[TIP]
====
There are a few restrictions due to the fact that CGLIB dynamically adds features at
startup-time:
startup-time, in particular that configuration classes must not be final and need to
have a default constructor with no arguments.
* Configuration classes should not be final
* They should have a constructor with no arguments
If you prefer to avoid any CGLIB-imposed limitations, consider declaring your `@Bean`
methods on non-`@Configuration` classes, e.g. on plain `@Component` classes instead.
Cross-method calls between `@Bean` methods won't get intercepted then, so you'll have
to exclusively rely on dependency injection at the field or method level there.
====
@ -6688,6 +6690,14 @@ This approach simplifies container instantiation, as only one class needs to be @@ -6688,6 +6690,14 @@ This approach simplifies container instantiation, as only one class needs to be
with, rather than requiring the developer to remember a potentially large number of
`@Configuration` classes during construction.
[TIP]
====
As of Spring Framework 4.2, `@Import` also supports references to regular component
classes, analogous to the `AnnotationConfigApplicationContext.register` method.
This is particularly useful if you'd like to avoid component scanning, using a few
configuration classes as entry points for explicitly defining all your components.
====
[[beans-java-injecting-imported-beans]]
===== Injecting dependencies on imported @Bean definitions

Loading…
Cancel
Save