Skip to content

@Autowired/@Value does not work on inner bean in native #29803

Closed
@zcw159357

Description

@zcw159357

when using @Value or @Autowired inside a @Webfilter annotationed class and run in aot mode, it'll raise error

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean named '(inner bean)#5884a914' that could not be found.


Action:

Consider defining a bean named '(inner bean)#5884a914' in your configuration.

spring boot version 3.0.1

example project here
demo.zip

seems in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#obtainInstanceFromSupplier

if (supplier instanceof InstanceSupplier<?> instanceSupplier) {
	return instanceSupplier.get(RegisteredBean.of((ConfigurableListableBeanFactory) this, beanName));
}

inner beans can't be found by beanName, but WebFilterHandler uses inner bean to create filter.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions