Skip to content

Cannot configure LocalResolver bean in Sprint Boot 3.1.0 #36424

@snturk

Description

@snturk

Using Spring Boot 3.1.0, I cannot create a bean named "localeResolver" with type LocalResolver. When application starts, I get the following:

The bean 'localeResolver', defined in class path resource [path/to/MyConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class] and overriding is disabled.

And I'm defining LocaleResolver bean like that:

@Configuration
@EnableConfigurationProperties({SomePropertiesClasses})
public class MyConfiguration {
    private final MyClass myClass;

    public MessagesConfiguration(MyClass myClass) {
        this.myClass = myClass;
    }

    @Bean
    public LocaleResolver localeResolver() {
        // ...
    }
}

Without setting spring.main.allow-bean-definition-overriding=true I want to define a LocaleResolver bean.

Note: I don't have @EnableWebMvc annotation in my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions