Skip to content

Commit 322013a

Browse files
committed
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
1 parent 54839a7 commit 322013a

File tree

2 files changed

+5
-5
lines changed
  • framework-docs/modules/ROOT/pages/core/beans/java
  • spring-context/src/main/java/org/springframework/context/annotation

2 files changed

+5
-5
lines changed

framework-docs/modules/ROOT/pages/core/beans/java/basic-concepts.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The preceding `AppConfig` class is equivalent to the following Spring `<beans/>`
5959
****
6060
When `@Bean` methods are declared within classes that are not annotated with
6161
`@Configuration`, they are referred to as being processed in a "`lite`" mode. Bean methods
62-
declared in a `@Component` or even in a plain old class are considered to be "`lite`",
62+
declared on a bean that is not annotated with `@Configuration` are considered to be "`lite`",
6363
with a different primary purpose of the containing class and a `@Bean` method
6464
being a sort of bonus there. For example, service components may expose management views
6565
to the container through an additional `@Bean` method on each applicable component class.

spring-context/src/main/java/org/springframework/context/annotation/Bean.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -135,9 +135,9 @@
135135
* <h3>{@code @Bean} <em>Lite</em> Mode</h3>
136136
*
137137
* <p>{@code @Bean} methods may also be declared within classes that are <em>not</em>
138-
* annotated with {@code @Configuration}. For example, bean methods may be declared
139-
* in a {@code @Component} class or even in a <em>plain old class</em>. In such cases,
140-
* a {@code @Bean} method will get processed in a so-called <em>'lite'</em> mode.
138+
* annotated with {@code @Configuration}. If a bean methods is declared on a bean
139+
* that is <em>not</em> annotated with {@code @Configuration} it is processed in a
140+
* so-called <em>'lite'</em> mode.
141141
*
142142
* <p>Bean methods in <em>lite</em> mode will be treated as plain <em>factory
143143
* methods</em> by the container (similar to {@code factory-method} declarations

0 commit comments

Comments
 (0)