16
16
17
17
package org .springframework .boot .autoconfigure ;
18
18
19
+ import static org .springframework .util .StringUtils .commaDelimitedListToStringArray ;
20
+ import static org .springframework .util .StringUtils .trimAllWhitespace ;
21
+
19
22
import java .io .IOException ;
20
23
import java .nio .charset .Charset ;
21
24
import java .util .Iterator ;
24
27
import org .springframework .boot .autoconfigure .MessageSourceAutoConfiguration .ResourceBundleCondition ;
25
28
import org .springframework .boot .autoconfigure .condition .ConditionOutcome ;
26
29
import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
30
+ import org .springframework .boot .autoconfigure .condition .SearchStrategy ;
27
31
import org .springframework .boot .autoconfigure .condition .SpringBootCondition ;
28
32
import org .springframework .boot .context .properties .ConfigurationProperties ;
29
33
import org .springframework .boot .context .properties .EnableConfigurationProperties ;
40
44
import org .springframework .util .ConcurrentReferenceHashMap ;
41
45
import org .springframework .util .StringUtils ;
42
46
43
- import static org .springframework .util .StringUtils .commaDelimitedListToStringArray ;
44
- import static org .springframework .util .StringUtils .trimAllWhitespace ;
45
-
46
47
/**
47
48
* {@link EnableAutoConfiguration Auto-configuration} for {@link MessageSource}.
48
49
*
51
52
* @author Eddú Meléndez
52
53
*/
53
54
@ Configuration
54
- @ ConditionalOnMissingBean (MessageSource .class )
55
+ @ ConditionalOnMissingBean (value = MessageSource .class , search = SearchStrategy . CURRENT )
55
56
@ AutoConfigureOrder (Ordered .HIGHEST_PRECEDENCE )
56
57
@ Conditional (ResourceBundleCondition .class )
57
58
@ EnableConfigurationProperties
@@ -90,7 +91,7 @@ public MessageSource messageSource() {
90
91
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource ();
91
92
if (StringUtils .hasText (this .basename )) {
92
93
messageSource
93
- .setBasenames (commaDelimitedListToStringArray (trimAllWhitespace (this .basename )));
94
+ .setBasenames (commaDelimitedListToStringArray (trimAllWhitespace (this .basename )));
94
95
}
95
96
if (this .encoding != null ) {
96
97
messageSource .setDefaultEncoding (this .encoding .name ());
@@ -166,7 +167,7 @@ private ConditionOutcome getMatchOutcomeForBasename(ConditionContext context,
166
167
private Resource [] getResources (ClassLoader classLoader , String name ) {
167
168
try {
168
169
return new SkipPatternPathMatchingResourcePatternResolver (classLoader )
169
- .getResources ("classpath*:" + name + "*.properties" );
170
+ .getResources ("classpath*:" + name + "*.properties" );
170
171
}
171
172
catch (Exception ex ) {
172
173
return NO_RESOURCES ;
@@ -180,7 +181,7 @@ private Resource[] getResources(ClassLoader classLoader, String name) {
180
181
* contain messages.properties.
181
182
*/
182
183
private static class SkipPatternPathMatchingResourcePatternResolver extends
183
- PathMatchingResourcePatternResolver {
184
+ PathMatchingResourcePatternResolver {
184
185
185
186
private static final ClassLoader ROOT_CLASSLOADER ;
186
187
static {
@@ -197,14 +198,14 @@ private static class SkipPatternPathMatchingResourcePatternResolver extends
197
198
}
198
199
199
200
private static final String [] SKIPPED = { "aspectjweaver-" , "hibernate-core-" ,
200
- "hsqldb-" , "jackson-annotations-" , "jackson-core-" , "jackson-databind-" ,
201
- "javassist-" , "snakeyaml-" , "spring-aop-" , "spring-beans-" ,
202
- "spring-boot-" , "spring-boot-actuator-" , "spring-boot-autoconfigure-" ,
203
- "spring-core-" , "spring-context-" , "spring-data-commons-" ,
204
- "spring-expression-" , "spring-jdbc-" , "spring-orm-" , "spring-tx-" ,
205
- "spring-web-" , "spring-webmvc-" , "tomcat-embed-" , "joda-time-" ,
206
- "hibernate-entitymanager-" , "hibernate-validator-" , "logback-classic-" ,
207
- "logback-core-" , "thymeleaf-" };
201
+ "hsqldb-" , "jackson-annotations-" , "jackson-core-" , "jackson-databind-" ,
202
+ "javassist-" , "snakeyaml-" , "spring-aop-" , "spring-beans-" ,
203
+ "spring-boot-" , "spring-boot-actuator-" , "spring-boot-autoconfigure-" ,
204
+ "spring-core-" , "spring-context-" , "spring-data-commons-" ,
205
+ "spring-expression-" , "spring-jdbc-" , "spring-orm-" , "spring-tx-" ,
206
+ "spring-web-" , "spring-webmvc-" , "tomcat-embed-" , "joda-time-" ,
207
+ "hibernate-entitymanager-" , "hibernate-validator-" , "logback-classic-" ,
208
+ "logback-core-" , "thymeleaf-" };
208
209
209
210
public SkipPatternPathMatchingResourcePatternResolver (ClassLoader classLoader ) {
210
211
super (classLoader );
0 commit comments