Skip to content

Commit cbc7328

Browse files
committed
Use EnableConfigurationProperties to define MessageSourceProperties
Closes gh-42181
1 parent ea5ec6f commit cbc7328

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfiguration.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -30,7 +30,6 @@
3030
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
3131
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.MessageSourceRuntimeHints;
3232
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.ResourceBundleCondition;
33-
import org.springframework.boot.context.properties.ConfigurationProperties;
3433
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3534
import org.springframework.context.MessageSource;
3635
import org.springframework.context.annotation.Bean;
@@ -59,18 +58,12 @@
5958
@ConditionalOnMissingBean(name = AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME, search = SearchStrategy.CURRENT)
6059
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
6160
@Conditional(ResourceBundleCondition.class)
62-
@EnableConfigurationProperties
61+
@EnableConfigurationProperties(MessageSourceProperties.class)
6362
@ImportRuntimeHints(MessageSourceRuntimeHints.class)
6463
public class MessageSourceAutoConfiguration {
6564

6665
private static final Resource[] NO_RESOURCES = {};
6766

68-
@Bean
69-
@ConfigurationProperties(prefix = "spring.messages")
70-
public MessageSourceProperties messageSourceProperties() {
71-
return new MessageSourceProperties();
72-
}
73-
7467
@Bean
7568
public MessageSource messageSource(MessageSourceProperties properties) {
7669
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -21,6 +21,7 @@
2121
import java.time.Duration;
2222
import java.time.temporal.ChronoUnit;
2323

24+
import org.springframework.boot.context.properties.ConfigurationProperties;
2425
import org.springframework.boot.convert.DurationUnit;
2526

2627
/**
@@ -30,6 +31,7 @@
3031
* @author Kedar Joshi
3132
* @since 2.0.0
3233
*/
34+
@ConfigurationProperties(prefix = "spring.messages")
3335
public class MessageSourceProperties {
3436

3537
/**

0 commit comments

Comments
 (0)