Skip to content

@Component class using @Value cannot access @PropertySource proeprties [SPR-8516] #13161

Closed
@spring-projects-issues

Description

@spring-projects-issues

Marcel Overdijk opened SPR-8516 and commented

I'm using a @Configuration class like:

@Configuration
@ComponentScan(basePackages = {"nl.vooty"}, excludeFilters = {@Filter(type = FilterType.ANNOTATION, value = Configuration.class)})
@PropertySource("classpath:/META-INF/config.properties")
public class AppConfig {
    ..
}

In a @Component class I would like to inject a property value using the @Value annotation like:

@Component
public class AuthenticationFailureBadCredentialsListener implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
    
    @Value("${authentication.max.login.failures}")
    private String maxLoginFailures;

    ..
}

Although the property exists, it's not injected in the variable.

When logging the value of the maxLoginFailures it is: "${authentication.max.login.failures}"

Note that I'm testing on M2.


Affects: 3.1 M2

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions