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
5b36484b
Commit
5b36484b
authored
Aug 28, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1433 from liujiong1982/spring-boot-1379
* spring-boot-1379: Add database property to RedisProperties
parents
2186da45
b1ceb8a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
RedisAutoConfiguration.java
...work/boot/autoconfigure/redis/RedisAutoConfiguration.java
+2
-0
RedisProperties.java
...ngframework/boot/autoconfigure/redis/RedisProperties.java
+10
-0
RedisAutoConfigurationTests.java
...boot/autoconfigure/redis/RedisAutoConfigurationTests.java
+2
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfiguration.java
View file @
5b36484b
...
@@ -65,6 +65,7 @@ public class RedisAutoConfiguration {
...
@@ -65,6 +65,7 @@ public class RedisAutoConfiguration {
if
(
this
.
properties
.
getPassword
()
!=
null
)
{
if
(
this
.
properties
.
getPassword
()
!=
null
)
{
factory
.
setPassword
(
this
.
properties
.
getPassword
());
factory
.
setPassword
(
this
.
properties
.
getPassword
());
}
}
factory
.
setDatabase
(
this
.
properties
.
getDatabase
());
return
factory
;
return
factory
;
}
}
...
@@ -86,6 +87,7 @@ public class RedisAutoConfiguration {
...
@@ -86,6 +87,7 @@ public class RedisAutoConfiguration {
if
(
this
.
properties
.
getPassword
()
!=
null
)
{
if
(
this
.
properties
.
getPassword
()
!=
null
)
{
factory
.
setPassword
(
this
.
properties
.
getPassword
());
factory
.
setPassword
(
this
.
properties
.
getPassword
());
}
}
factory
.
setDatabase
(
this
.
properties
.
getDatabase
());
return
factory
;
return
factory
;
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/redis/RedisProperties.java
View file @
5b36484b
...
@@ -26,6 +26,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -26,6 +26,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties
(
prefix
=
"spring.redis"
)
@ConfigurationProperties
(
prefix
=
"spring.redis"
)
public
class
RedisProperties
{
public
class
RedisProperties
{
private
int
database
=
0
;
private
String
host
=
"localhost"
;
private
String
host
=
"localhost"
;
private
String
password
;
private
String
password
;
...
@@ -66,6 +68,14 @@ public class RedisProperties {
...
@@ -66,6 +68,14 @@ public class RedisProperties {
this
.
pool
=
pool
;
this
.
pool
=
pool
;
}
}
public
int
getDatabase
()
{
return
this
.
database
;
}
public
void
setDatabase
(
int
database
)
{
this
.
database
=
database
;
}
/**
/**
* Pool properties.
* Pool properties.
*/
*/
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfigurationTests.java
View file @
5b36484b
...
@@ -51,11 +51,13 @@ public class RedisAutoConfigurationTests {
...
@@ -51,11 +51,13 @@ public class RedisAutoConfigurationTests {
public
void
testOverrideRedisConfiguration
()
throws
Exception
{
public
void
testOverrideRedisConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.redis.host:foo"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.redis.host:foo"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.redis.database:1"
);
this
.
context
.
register
(
RedisAutoConfiguration
.
class
,
this
.
context
.
register
(
RedisAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
)
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
)
.
getHostName
());
.
getHostName
());
assertEquals
(
1
,
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getDatabase
());
}
}
@Test
@Test
...
...
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