Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
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
周健威
rs-cloud-platform
Commits
9332e106
Commit
9332e106
authored
Nov 24, 2020
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改database设置没有生效的问题
parent
5b18163e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
180 additions
and
1 deletion
+180
-1
pom.xml
ace-common/pom.xml
+10
-1
RedisConfig.java
...ommon/src/main/java/com/ace/cache/config/RedisConfig.java
+170
-0
No files found.
ace-common/pom.xml
View file @
9332e106
...
...
@@ -12,6 +12,16 @@
<artifactId>
ace-common
</artifactId>
<version>
2.0-rscp-SNAPSHOT
</version>
<repositories>
<repository>
<id>
mvn-repo
</id>
<url>
https://raw.github.com/wxiaoqi/ace-cache/master
</url>
<snapshots>
<enabled>
true
</enabled>
<updatePolicy>
always
</updatePolicy>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
...
...
@@ -141,7 +151,6 @@
<groupId>
com.github.wxiaoqi
</groupId>
<artifactId>
ace-cache
</artifactId>
<version>
0.0.2
</version>
<scope>
compile
</scope>
</dependency>
<!-- excel 组件 -->
...
...
ace-common/src/main/java/com/ace/cache/config/RedisConfig.java
0 → 100644
View file @
9332e106
package
com
.
ace
.
cache
.
config
;
import
com.ace.cache.utils.PropertiesLoaderUtils
;
import
javax.annotation.PostConstruct
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.Environment
;
import
redis.clients.jedis.JedisPool
;
import
redis.clients.jedis.JedisPoolConfig
;
@Configuration
public
class
RedisConfig
{
@Autowired
private
Environment
env
;
private
JedisPool
pool
;
private
String
maxActive
;
private
String
maxIdle
;
private
String
maxWait
;
private
String
host
;
private
String
password
;
private
String
timeout
;
private
String
database
;
private
String
port
;
private
String
enable
;
private
String
sysName
;
public
RedisConfig
()
{
}
@PostConstruct
public
void
init
()
{
PropertiesLoaderUtils
prop
=
new
PropertiesLoaderUtils
(
new
String
[]{
"application.properties"
});
this
.
host
=
prop
.
getProperty
(
"redis.host"
);
if
(
StringUtils
.
isBlank
(
this
.
host
))
{
this
.
host
=
this
.
env
.
getProperty
(
"redis.host"
);
this
.
maxActive
=
this
.
env
.
getProperty
(
"redis.pool.maxActive"
);
this
.
maxIdle
=
this
.
env
.
getProperty
(
"redis.pool.maxIdle"
);
this
.
maxWait
=
this
.
env
.
getProperty
(
"redis.pool.maxWait"
);
this
.
password
=
this
.
env
.
getProperty
(
"redis.password"
);
this
.
timeout
=
this
.
env
.
getProperty
(
"redis.timeout"
);
this
.
database
=
this
.
env
.
getProperty
(
"redis.database"
);
this
.
port
=
this
.
env
.
getProperty
(
"redis.port"
);
this
.
sysName
=
this
.
env
.
getProperty
(
"redis.sysName"
);
this
.
enable
=
this
.
env
.
getProperty
(
"redis.enable"
);
}
else
{
this
.
maxActive
=
prop
.
getProperty
(
"redis.pool.maxActive"
);
this
.
maxIdle
=
prop
.
getProperty
(
"redis.pool.maxIdle"
);
this
.
maxWait
=
prop
.
getProperty
(
"redis.pool.maxWait"
);
this
.
password
=
prop
.
getProperty
(
"redis.password"
);
this
.
timeout
=
prop
.
getProperty
(
"redis.timeout"
);
this
.
database
=
prop
.
getProperty
(
"redis.database"
);
this
.
port
=
prop
.
getProperty
(
"redis.port"
);
this
.
sysName
=
prop
.
getProperty
(
"redis.sysName"
);
this
.
enable
=
prop
.
getProperty
(
"redis.enable"
);
}
}
@Bean
public
JedisPoolConfig
constructJedisPoolConfig
()
{
JedisPoolConfig
config
=
new
JedisPoolConfig
();
config
.
setMaxTotal
(
Integer
.
parseInt
(
this
.
maxActive
));
config
.
setMaxIdle
(
Integer
.
parseInt
(
this
.
maxIdle
));
config
.
setMaxWaitMillis
((
long
)
Integer
.
parseInt
(
this
.
maxWait
));
config
.
setTestOnBorrow
(
true
);
return
config
;
}
@Bean
(
name
=
{
"pool"
}
)
public
JedisPool
constructJedisPool
()
{
String
ip
=
this
.
host
;
int
port
=
Integer
.
parseInt
(
this
.
port
);
String
password
=
this
.
password
;
int
timeout
=
Integer
.
parseInt
(
this
.
timeout
);
int
database
=
Integer
.
parseInt
(
this
.
database
);
if
(
null
==
this
.
pool
)
{
if
(
StringUtils
.
isBlank
(
password
))
{
this
.
pool
=
new
JedisPool
(
this
.
constructJedisPoolConfig
(),
ip
,
port
,
timeout
,(
String
)
null
,
database
);
}
else
{
this
.
pool
=
new
JedisPool
(
this
.
constructJedisPoolConfig
(),
ip
,
port
,
timeout
,
password
,
database
);
}
}
return
this
.
pool
;
}
public
String
getMaxActive
()
{
return
this
.
maxActive
;
}
public
void
setMaxActive
(
String
maxActive
)
{
this
.
maxActive
=
maxActive
;
}
public
String
getMaxIdle
()
{
return
this
.
maxIdle
;
}
public
void
setMaxIdle
(
String
maxIdle
)
{
this
.
maxIdle
=
maxIdle
;
}
public
String
getMaxWait
()
{
return
this
.
maxWait
;
}
public
void
setMaxWait
(
String
maxWait
)
{
this
.
maxWait
=
maxWait
;
}
public
String
getHost
()
{
return
this
.
host
;
}
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
}
public
String
getPassword
()
{
return
this
.
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getTimeout
()
{
return
this
.
timeout
;
}
public
void
setTimeout
(
String
timeout
)
{
this
.
timeout
=
timeout
;
}
public
String
getDatabase
()
{
return
this
.
database
;
}
public
void
setDatabase
(
String
database
)
{
this
.
database
=
database
;
}
public
String
getSysName
()
{
return
this
.
sysName
;
}
public
void
setSysName
(
String
sysName
)
{
this
.
sysName
=
sysName
;
}
public
String
getEnable
()
{
return
this
.
enable
;
}
public
void
setEnable
(
String
enable
)
{
this
.
enable
=
enable
;
}
public
String
getPort
()
{
return
this
.
port
;
}
public
void
setPort
(
String
port
)
{
this
.
port
=
port
;
}
}
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