Use EnableConfigurationProperties to define MessageSourceProperties
Closes gh-42181
This commit is contained in:
parent
ea5ec6fd22
commit
cbc732832b
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.condition.SpringBootCondition;
|
||||||
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.MessageSourceRuntimeHints;
|
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.MessageSourceRuntimeHints;
|
||||||
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.ResourceBundleCondition;
|
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.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.annotation.Bean;
|
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)
|
@ConditionalOnMissingBean(name = AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME, search = SearchStrategy.CURRENT)
|
||||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||||
@Conditional(ResourceBundleCondition.class)
|
@Conditional(ResourceBundleCondition.class)
|
||||||
@EnableConfigurationProperties
|
@EnableConfigurationProperties(MessageSourceProperties.class)
|
||||||
@ImportRuntimeHints(MessageSourceRuntimeHints.class)
|
@ImportRuntimeHints(MessageSourceRuntimeHints.class)
|
||||||
public class MessageSourceAutoConfiguration {
|
public class MessageSourceAutoConfiguration {
|
||||||
|
|
||||||
private static final Resource[] NO_RESOURCES = {};
|
private static final Resource[] NO_RESOURCES = {};
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConfigurationProperties(prefix = "spring.messages")
|
|
||||||
public MessageSourceProperties messageSourceProperties() {
|
|
||||||
return new MessageSourceProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MessageSource messageSource(MessageSourceProperties properties) {
|
public MessageSource messageSource(MessageSourceProperties properties) {
|
||||||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.Duration;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.convert.DurationUnit;
|
import org.springframework.boot.convert.DurationUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,6 +31,7 @@ import org.springframework.boot.convert.DurationUnit;
|
||||||
* @author Kedar Joshi
|
* @author Kedar Joshi
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "spring.messages")
|
||||||
public class MessageSourceProperties {
|
public class MessageSourceProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue