Support @Value for record injection

Add @Value support for record injection by disabling populateBean() for
records, since records are immutable.

See gh-28770
Closes gh-28774
This commit is contained in:
nanfeng
2022-07-08 10:59:55 +08:00
committed by Sam Brannen
parent c859211f7a
commit 7c9fc575ff
2 changed files with 18 additions and 0 deletions

View File

@@ -1353,6 +1353,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param bw the BeanWrapper with bean instance
*/
protected void populateBean(String beanName, RootBeanDefinition mbd, @Nullable BeanWrapper bw) {
// record has not set methods
if (mbd.getBeanClass().isRecord()) {
return;
}
if (bw == null) {
if (mbd.hasPropertyValues()) {
throw new BeanCreationException(