From 322013a30a620c207a40e37a34bef34192ed0037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 24 Oct 2023 16:00:37 +0200 Subject: [PATCH] Clarify the semantic of lite mode This commit removes the "plain old class" bit of the documentation as it may be confusing. The gist of it is that it must be a bean but not annotated with `@Configuration` so the updated sentence states exactly that. Closes gh-29957 --- .../ROOT/pages/core/beans/java/basic-concepts.adoc | 2 +- .../java/org/springframework/context/annotation/Bean.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/beans/java/basic-concepts.adoc b/framework-docs/modules/ROOT/pages/core/beans/java/basic-concepts.adoc index f90a2752b7..80794f693e 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/java/basic-concepts.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/java/basic-concepts.adoc @@ -59,7 +59,7 @@ The preceding `AppConfig` class is equivalent to the following Spring `` **** When `@Bean` methods are declared within classes that are not annotated with `@Configuration`, they are referred to as being processed in a "`lite`" mode. Bean methods -declared in a `@Component` or even in a plain old class are considered to be "`lite`", +declared on a bean that is not annotated with `@Configuration` are considered to be "`lite`", with a different primary purpose of the containing class and a `@Bean` method being a sort of bonus there. For example, service components may expose management views to the container through an additional `@Bean` method on each applicable component class. diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java index 14732b1783..ac92d71084 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -135,9 +135,9 @@ import org.springframework.core.annotation.AliasFor; *

{@code @Bean} Lite Mode

* *

{@code @Bean} methods may also be declared within classes that are not - * annotated with {@code @Configuration}. For example, bean methods may be declared - * in a {@code @Component} class or even in a plain old class. In such cases, - * a {@code @Bean} method will get processed in a so-called 'lite' mode. + * annotated with {@code @Configuration}. If a bean methods is declared on a bean + * that is not annotated with {@code @Configuration} it is processed in a + * so-called 'lite' mode. * *

Bean methods in lite mode will be treated as plain factory * methods by the container (similar to {@code factory-method} declarations