From 61b5b1edd8d0358cb143d618691c87b9fd54f639 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:29:30 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20example=20for=20@=E2=81=A0ImportResource?= =?UTF-8?q?=20in=20the=20reference=20manual?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this commit, the main() method attempted to retrieve a TransferService bean from the context, but no such bean had been configured in the context. This commit addresses that by configuring a TransferService bean in the context. Closes gh-33446 --- .../java/composing-configuration-classes.adoc | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/framework-docs/modules/ROOT/pages/core/beans/java/composing-configuration-classes.adoc b/framework-docs/modules/ROOT/pages/core/beans/java/composing-configuration-classes.adoc index a30f5c26e2..d09faa734e 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/java/composing-configuration-classes.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/java/composing-configuration-classes.adoc @@ -627,7 +627,7 @@ Java:: @Bean public TransferService transferService() { - return new TransferService(accountRepository()); + return new TransferServiceImpl(accountRepository()); } } ---- @@ -776,6 +776,17 @@ Java:: public DataSource dataSource() { return new DriverManagerDataSource(url, username, password); } + + @Bean + public AccountRepository accountRepository(DataSource dataSource) { + return new JdbcAccountRepository(dataSource); + } + + @Bean + public TransferService transferService(AccountRepository accountRepository) { + return new TransferServiceImpl(accountRepository); + } + } ---- @@ -800,6 +811,17 @@ Kotlin:: fun dataSource(): DataSource { return DriverManagerDataSource(url, username, password) } + + @Bean + fun accountRepository(dataSource: DataSource): AccountRepository { + return JdbcAccountRepository(dataSource) + } + + @Bean + fun transferService(accountRepository: AccountRepository): TransferService { + return TransferServiceImpl(accountRepository) + } + } ---- ======