Skip to content

Commit 62eb21f

Browse files
committed
Add note on declaring autowired fields as ObjectProvider
Closes gh-33834
1 parent 01c85b1 commit 62eb21f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurer.java

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
* {@link #cacheManager()}, {@link #cacheResolver()}, {@link #keyGenerator()}, and
3333
* {@link #errorHandler()} for detailed instructions.
3434
*
35+
* <p><b>NOTE: A {@code CachingConfigurer} will get initialized early.</b>
36+
* Do not inject common dependencies into autowired fields directly; instead, consider
37+
* declaring a lazy {@link org.springframework.beans.factory.ObjectProvider} for those.
38+
*
3539
* @author Chris Beams
3640
* @author Stephane Nicoll
3741
* @since 3.1

Diff for: spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionManagementConfigurer.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,10 @@
3030
* <p>See @{@link EnableTransactionManagement} for general examples and context;
3131
* see {@link #annotationDrivenTransactionManager()} for detailed instructions.
3232
*
33+
* <p><b>NOTE: A {@code TransactionManagementConfigurer} will get initialized early.</b>
34+
* Do not inject common dependencies into autowired fields directly; instead, consider
35+
* declaring a lazy {@link org.springframework.beans.factory.ObjectProvider} for those.
36+
*
3337
* <p>Note that in by-type lookup disambiguation cases, an alternative approach to
3438
* implementing this interface is to simply mark one of the offending
3539
* {@code PlatformTransactionManager} {@code @Bean} methods (or

0 commit comments

Comments
 (0)