@ -113,7 +113,8 @@ issue, because no compiler is involved, and you can declare
@@ -113,7 +113,8 @@ issue, because no compiler is involved, and you can declare
When using `@Configuration` classes, the Java compiler places constraints on
the configuration model, in that references to other beans must be valid Java syntax.
Fortunately, solving this problem is simple. As xref:core/beans/java/bean-annotation.adoc#beans-java-dependencies[we already discussed],
There is another way to achieve the same result. Remember that `@Configuration` classes are
ultimately only another bean in the container: This means that they can take advantage of
`@Autowired` and `@Value` injection and other features the same as any other bean.
@ -216,6 +216,11 @@ classes are processed quite early during the initialization of the context, and
@@ -216,6 +216,11 @@ classes are processed quite early during the initialization of the context, and
to be injected this way may lead to unexpected early initialization. Whenever possible, resort to
parameter-based injection, as in the preceding example.
Avoid access to locally defined beans within a `@PostConstruct` method on the same configuration
class. This effectively leads to a circular reference since non-static `@Bean` methods semantically
require a fully initialized configuration class instance to be called on. With circular references
disallowed (e.g. in Spring Boot 2.6+), this may trigger a `BeanCurrentlyInCreationException`.
Also, be particularly careful with `BeanPostProcessor` and `BeanFactoryPostProcessor` definitions
through `@Bean`. Those should usually be declared as `static @Bean` methods, not triggering the
instantiation of their containing configuration class. Otherwise, `@Autowired` and `@Value` may not
@ -252,24 +252,24 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
@@ -252,24 +252,24 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
@ -209,7 +209,7 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
@@ -209,7 +209,7 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
@ -233,7 +233,10 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
@@ -233,7 +233,10 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
logger.debug("Starting R2DBC transaction on Connection ["+con+"] using ["+transactionDefinition+"]");
@ -354,12 +357,22 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
@@ -354,12 +357,22 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
if(logger.isDebugEnabled()){
logger.debug("Releasing R2DBC Connection ["+con+"] after transaction");
ex->logger.debug(String.format("Error ignored during cleanup: %s",ex)));
releaseMono=releaseMono.doOnError(ex->
logger.debug(String.format("Error ignored during connection release: %s",ex)));
}
returnreleaseMono.onErrorComplete();
releaseMono=releaseMono.onErrorComplete();
returnrestoreMono.then(releaseMono);
}
}
finally{
@ -482,6 +495,8 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
@@ -482,6 +495,8 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
privatebooleannewConnectionHolder;
privatebooleanmustRestoreAutoCommit;
@Nullable
privateStringsavepointName;
@ -507,6 +522,14 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
@@ -507,6 +522,14 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
@ -170,9 +170,8 @@ final class DefaultDatabaseClient implements DatabaseClient {
@@ -170,9 +170,8 @@ final class DefaultDatabaseClient implements DatabaseClient {