@@ -2946,7 +2946,6 @@ to perform certain actions upon initialization and destruction of your beans.
2946
2946
2947
2947
[TIP]
2948
2948
====
2949
-
2950
2949
The JSR-250 `@PostConstruct` and `@PreDestroy` annotations are generally considered best
2951
2950
practice for receiving lifecycle callbacks in a modern Spring application. Using these
2952
2951
annotations means that your beans are not coupled to Spring specific interfaces. For
@@ -6715,13 +6714,17 @@ The behavior could be different according to the scope of your bean. We are talk
6715
6714
about singletons here.
6716
6715
====
6717
6716
6718
- [NOTE ]
6717
+ [TIP ]
6719
6718
====
6720
6719
There are a few restrictions due to the fact that CGLIB dynamically adds features at
6721
- startup-time:
6720
+ startup-time, in particular that configuration classes must not be final. However, as
6721
+ of 4.3, any constructors are allowed on configuration classes, including the use of
6722
+ `@Autowired` or a single non-default constructor declaration for default injection.
6722
6723
6723
- * Configuration classes should not be final
6724
- * They should have a constructor with no arguments
6724
+ If you prefer to avoid any CGLIB-imposed limitations, consider declaring your `@Bean`
6725
+ methods on non-`@Configuration` classes, e.g. on plain `@Component` classes instead.
6726
+ Cross-method calls between `@Bean` methods won't get intercepted then, so you'll have
6727
+ to exclusively rely on dependency injection at the constructor or method level there.
6725
6728
====
6726
6729
6727
6730
@@ -6781,6 +6784,14 @@ This approach simplifies container instantiation, as only one class needs to be
6781
6784
with, rather than requiring the developer to remember a potentially large number of
6782
6785
`@Configuration` classes during construction.
6783
6786
6787
+ [TIP]
6788
+ ====
6789
+ As of Spring Framework 4.2, `@Import` also supports references to regular component
6790
+ classes, analogous to the `AnnotationConfigApplicationContext.register` method.
6791
+ This is particularly useful if you'd like to avoid component scanning, using a few
6792
+ configuration classes as entry points for explicitly defining all your components.
6793
+ ====
6794
+
6784
6795
[[beans-java-injecting-imported-beans]]
6785
6796
===== Injecting dependencies on imported @Bean definitions
6786
6797
0 commit comments