Fyro opened SPR-13874 and commented
It seems that there is not currently support for encoding/charset in @PropertySource("classpath:/...")
.
With french characters like "Générales", current result is "Générales" because there is no check with charset/encoding.
Default constructor with default charset, it's ok.
public EncodedResource(Resource resource) {
this(resource, null, Charset.defaultCharset());
}
Used in ConfigurationClassParser#processPropertySource
/**
* Create a PropertySource having the given name based on Properties
* loaded from the given encoded resource.
*/
public ResourcePropertySource(String name, Resource resource) throws IOException {
super(name, PropertiesLoaderUtils.loadProperties(new EncodedResource(resource)));
this.resourceName = getNameForResource(resource);
}
/**
* Create a PropertySource based on Properties loaded from the given resource.
* The name of the PropertySource will be generated based on the
* {@link Resource#getDescription() description} of the given resource.
*/
public ResourcePropertySource(Resource resource) throws IOException {
super(getNameForResource(resource), PropertiesLoaderUtils.loadProperties(new EncodedResource(resource)));
this.resourceName = null;
}
Affects: 4.2.4
Issue Links:
- #13603 Allow the use of custom PropertySource annotations in @Configuration
classes
- #18454 ResourcePropertySource class should support to specify character encoding
Referenced from: commits https://github.com/spring-projects/spring-framework/commit/a3a5a03ee36d259f6d06b679ec62e93d58678c71
Comment From: spring-projects-issues
Juergen Hoeller commented
I've added a corresponding encoding
attribute to @PropertySource
, allowing for a specific encoding to be associated with the given resources.
Juergen