Use EnableConfigurationProperties to define MessageSourceProperties
Closes gh-42181
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.MessageSourceRuntimeHints;
|
||||
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.ResourceBundleCondition;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -59,18 +58,12 @@ import org.springframework.util.StringUtils;
|
||||
@ConditionalOnMissingBean(name = AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME, search = SearchStrategy.CURRENT)
|
||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||
@Conditional(ResourceBundleCondition.class)
|
||||
@EnableConfigurationProperties
|
||||
@EnableConfigurationProperties(MessageSourceProperties.class)
|
||||
@ImportRuntimeHints(MessageSourceRuntimeHints.class)
|
||||
public class MessageSourceAutoConfiguration {
|
||||
|
||||
private static final Resource[] NO_RESOURCES = {};
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.messages")
|
||||
public MessageSourceProperties messageSourceProperties() {
|
||||
return new MessageSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageSource messageSource(MessageSourceProperties properties) {
|
||||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.convert.DurationUnit;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,7 @@ import org.springframework.boot.convert.DurationUnit;
|
||||
* @author Kedar Joshi
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.messages")
|
||||
public class MessageSourceProperties {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user