Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d6a424f9
Commit
d6a424f9
authored
Nov 26, 2015
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for UTF-8 in application.properties
Fixes gh-4622
parent
9a60f740
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
PropertiesPropertySourceLoader.java
...ingframework/boot/env/PropertiesPropertySourceLoader.java
+3
-1
PropertiesPropertySourceLoaderTests.java
...amework/boot/env/PropertiesPropertySourceLoaderTests.java
+7
-0
test-encoded.properties
...rces/org/springframework/boot/env/test-encoded.properties
+1
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/env/PropertiesPropertySourceLoader.java
View file @
d6a424f9
...
...
@@ -22,6 +22,7 @@ import java.util.Properties;
import
org.springframework.core.env.PropertiesPropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.EncodedResource
;
import
org.springframework.core.io.support.PropertiesLoaderUtils
;
/**
...
...
@@ -41,7 +42,8 @@ public class PropertiesPropertySourceLoader implements PropertySourceLoader {
public
PropertySource
<?>
load
(
String
name
,
Resource
resource
,
String
profile
)
throws
IOException
{
if
(
profile
==
null
)
{
Properties
properties
=
PropertiesLoaderUtils
.
loadProperties
(
resource
);
Properties
properties
=
PropertiesLoaderUtils
.
loadProperties
(
new
EncodedResource
(
resource
,
"UTF-8"
));
if
(!
properties
.
isEmpty
())
{
return
new
PropertiesPropertySource
(
name
,
properties
);
}
...
...
spring-boot/src/test/java/org/springframework/boot/env/PropertiesPropertySourceLoaderTests.java
View file @
d6a424f9
...
...
@@ -46,6 +46,13 @@ public class PropertiesPropertySourceLoaderTests {
assertThat
(
source
.
getProperty
(
"test"
),
equalTo
((
Object
)
"properties"
));
}
@Test
public
void
loadPropertiesEncoded
()
throws
Exception
{
PropertySource
<?>
source
=
this
.
loader
.
load
(
"encoded.properties"
,
new
ClassPathResource
(
"test-encoded.properties"
,
getClass
()),
null
);
assertThat
(
source
.
getProperty
(
"test"
),
equalTo
((
Object
)
"prकperties"
));
}
@Test
public
void
loadXml
()
throws
Exception
{
PropertySource
<?>
source
=
this
.
loader
.
load
(
"test.xml"
,
...
...
spring-boot/src/test/resources/org/springframework/boot/env/test-encoded.properties
0 → 100644
View file @
d6a424f9
test
=
prकperties
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment