Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
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
李丛阳
education
Commits
a35cbcda
Commit
a35cbcda
authored
Jan 08, 2018
by
李丛阳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis
parent
13c4bfb2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
271 additions
and
13 deletions
+271
-13
pom.xml
pom.xml
+7
-0
RedisConfig.java
src/main/java/org/rcisoft/config/RedisConfig.java
+62
-0
SecurityConfig.java
src/main/java/org/rcisoft/config/SecurityConfig.java
+12
-9
RcRedisConfigBean.java
src/main/java/org/rcisoft/core/bean/RcRedisConfigBean.java
+41
-0
JwtAuthenTokenFilter.java
.../java/org/rcisoft/core/security/JwtAuthenTokenFilter.java
+2
-0
RcRedisService.java
src/main/java/org/rcisoft/core/service/RcRedisService.java
+18
-0
RcRedisServiceImpl.java
...ava/org/rcisoft/core/service/impl/RcRedisServiceImpl.java
+64
-0
application-dev.yml
src/main/resources/application-dev.yml
+15
-4
application-prod.yml
src/main/resources/application-prod.yml
+10
-0
architecture.md
src/main/resources/architecture.md
+40
-0
No files found.
pom.xml
View file @
a35cbcda
...
...
@@ -91,6 +91,13 @@
<artifactId>
spring-boot-starter-aop
</artifactId>
</dependency>
<!--spring boot redis starter-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<!--spring boot mybatis starter-->
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
...
...
src/main/java/org/rcisoft/config/RedisConfig.java
0 → 100644
View file @
a35cbcda
package
org
.
rcisoft
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.core.bean.RcRedisConfigBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
redis.clients.jedis.JedisPool
;
import
redis.clients.jedis.JedisPoolConfig
;
import
static
sun
.
jvm
.
hotspot
.
oops
.
CellTypeState
.
addr
;
/**
* Created by lcy on 18/1/8.
*/
@Configuration
@Slf4j
public
class
RedisConfig
{
@Autowired
private
RcRedisConfigBean
redisConfigBean
;
@Bean
public
JedisPool
getJedisPool
(){
JedisPoolConfig
config
=
new
JedisPoolConfig
();
//连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true
config
.
setBlockWhenExhausted
(
true
);
//设置的逐出策略类名, 默认DefaultEvictionPolicy(当连接超过最大空闲时间,或连接数超过最大空闲连接数)
config
.
setEvictionPolicyClassName
(
"org.apache.commons.pool2.impl.DefaultEvictionPolicy"
);
//是否启用pool的jmx管理功能, 默认true
config
.
setJmxEnabled
(
true
);
//MBean ObjectName = new ObjectName("org.apache.commons.pool2:type=GenericObjectPool,name=" + "pool" + i); 默认为"pool", JMX不熟,具体不知道是干啥的...默认就好.
config
.
setJmxNamePrefix
(
"pool"
);
//是否启用后进先出, 默认true
config
.
setLifo
(
false
);
//最大空闲连接数, 默认8个
config
.
setMaxIdle
(
redisConfigBean
.
getMaxIdle
());
//最大连接数, 默认8个
config
.
setMaxTotal
(
redisConfigBean
.
getMaxActive
());
//获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1
config
.
setMaxWaitMillis
(
redisConfigBean
.
getMaxWait
());
//逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
config
.
setMinEvictableIdleTimeMillis
(
1800000
);
//最小空闲连接数, 默认0
config
.
setMinIdle
(
0
);
//每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3
config
.
setNumTestsPerEvictionRun
(
3
);
//对象空闲多久后逐出, 当空闲时间>该值 且 空闲连接>最大空闲数 时直接逐出,不再根据MinEvictableIdleTimeMillis判断 (默认逐出策略)
config
.
setSoftMinEvictableIdleTimeMillis
(
1800000
);
//在获取连接的时候检查有效性, 默认false
config
.
setTestOnBorrow
(
false
);
//在空闲时检查有效性, 默认false
config
.
setTestWhileIdle
(
false
);
//逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1
config
.
setTimeBetweenEvictionRunsMillis
(-
1
);
JedisPool
pool
=
new
JedisPool
(
config
,
redisConfigBean
.
getHost
(),
redisConfigBean
.
getPort
(),
redisConfigBean
.
getTimeout
(),
null
,
redisConfigBean
.
getDatabase
());
log
.
info
(
"init JedisPool ..."
);
return
pool
;
}
}
src/main/java/org/rcisoft/config/SecurityConfig.java
View file @
a35cbcda
...
...
@@ -24,6 +24,15 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
//开启prePostEnabled注解支持
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
/**
* 前置过滤器
* @return
*/
@Autowired
JwtAuthenTokenFilter
jwtAuthenTokenFilter
;
@Autowired
private
UserDetailsService
jwtUserDetailServiceImpl
;
...
...
@@ -51,14 +60,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return
new
JwtBean
();
}
/**
* 前置过滤器
* @return
*/
@Bean
JwtAuthenTokenFilter
authenticationTokenFilterBean
(){
return
new
JwtAuthenTokenFilter
();
}
@Override
...
...
@@ -94,9 +96,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.
authenticationEntryPoint
(
new
RestAuthenticationEntryPoint
())
;
http
//添加前置过滤器
.
addFilter
Before
(
authenticationTokenFilterBean
()
,
UsernamePasswordAuthenticationFilter
.
class
);
.
addFilter
After
(
jwtAuthenTokenFilter
,
UsernamePasswordAuthenticationFilter
.
class
);
http
//禁用header缓存
.
headers
().
cacheControl
();
}
}
src/main/java/org/rcisoft/core/bean/RcRedisConfigBean.java
0 → 100644
View file @
a35cbcda
package
org
.
rcisoft
.
core
.
bean
;
import
lombok.Data
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
/**
* Created by lcy on 18/1/8.
*/
@Component
@ConfigurationProperties
(
prefix
=
"spring.redis"
)
@Data
public
class
RcRedisConfigBean
{
private
String
host
;
private
int
port
;
private
String
password
;
private
int
timeout
;
private
int
database
;
@Value
(
"${spring.redis.pool.max-idle:100}"
)
private
int
maxIdle
;
@Value
(
"${spring.redis.pool.max-active:100}"
)
private
int
maxActive
;
@Value
(
"${spring.redis.pool.min-idle:1}"
)
private
int
minIdle
;
@Value
(
"${spring.redis.pool.max-wait:-1}"
)
private
int
maxWait
;
}
src/main/java/org/rcisoft/core/security/JwtAuthenTokenFilter.java
View file @
a35cbcda
...
...
@@ -9,6 +9,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.web.authentication.WebAuthenticationDetailsSource
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.filter.OncePerRequestFilter
;
import
javax.servlet.FilterChain
;
...
...
@@ -21,6 +22,7 @@ import java.io.IOException;
* Created by lcy on 17/11/21.
*/
@Slf4j
@Component
public
class
JwtAuthenTokenFilter
extends
OncePerRequestFilter
{
@Value
(
"${jwt.header}"
)
...
...
src/main/java/org/rcisoft/core/service/RcRedisService.java
0 → 100644
View file @
a35cbcda
package
org
.
rcisoft
.
core
.
service
;
import
redis.clients.jedis.Jedis
;
/**
* Created by lcy on 18/1/8.
*/
public
interface
RcRedisService
{
public
Jedis
getResource
();
public
void
returnResource
(
Jedis
jedis
);
public
void
set
(
String
key
,
String
value
);
public
String
get
(
String
key
);
}
src/main/java/org/rcisoft/core/service/impl/RcRedisServiceImpl.java
0 → 100644
View file @
a35cbcda
package
org
.
rcisoft
.
core
.
service
.
impl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.core.service.RcRedisService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
redis.clients.jedis.Jedis
;
import
redis.clients.jedis.JedisPool
;
/**
* Created by lcy on 18/1/8.
*/
@Service
@Slf4j
public
class
RcRedisServiceImpl
implements
RcRedisService
{
@Autowired
private
JedisPool
jedisPool
;
@Override
public
Jedis
getResource
()
{
return
jedisPool
.
getResource
();
}
@SuppressWarnings
(
"deprecation"
)
@Override
public
void
returnResource
(
Jedis
jedis
)
{
if
(
jedis
!=
null
){
jedisPool
.
returnResourceObject
(
jedis
);
}
}
@Override
public
void
set
(
String
key
,
String
value
)
{
Jedis
jedis
=
null
;
try
{
jedis
=
getResource
();
jedis
.
set
(
key
,
value
);
log
.
info
(
"Redis set success - "
+
key
+
", value:"
+
value
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"Redis set error: "
+
e
.
getMessage
()
+
" - "
+
key
+
", value:"
+
value
);
}
finally
{
returnResource
(
jedis
);
}
}
@Override
public
String
get
(
String
key
)
{
String
result
=
null
;
Jedis
jedis
=
null
;
try
{
jedis
=
getResource
();
result
=
jedis
.
get
(
key
);
log
.
info
(
"Redis get success - "
+
key
+
", value:"
+
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"Redis set error: "
+
e
.
getMessage
()
+
" - "
+
key
+
", value:"
+
result
);
}
finally
{
returnResource
(
jedis
);
}
return
result
;
}
}
src/main/resources/application-dev.yml
View file @
a35cbcda
server
:
port
:
8081
context-path
:
/edu
#ContextPath must start with '/' and not end with '/'
#
context-path: /edu #ContextPath must start with '/' and not end with '/'
tomcat
:
max-threads
:
300
#uri-encoding: UTF-8
...
...
@@ -11,9 +11,9 @@ server:
# org.springframework.web: DEBUG
druid
:
url
:
jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
url
:
jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
&useSSL=false
username
:
root
password
:
root
password
:
cy
initial-size
:
1
min-idle
:
1
max-active
:
20
...
...
@@ -53,6 +53,17 @@ spring:
throw-exception-if-no-handler-found
:
true
resources
:
add-mappings
:
false
redis
:
host
:
106.2.3.134
port
:
7481
pool
:
max-idle
:
50
max-active
:
1000
min-idle
:
5
max-wait
:
-1
database
:
0
password
:
'
'
springfox
:
...
...
@@ -102,7 +113,7 @@ global:
min_password
:
6
max_password
:
16
path
:
base_upload_server_location
:
E:\\eduFiles
base_upload_server_location
:
/working/resource/eduServer/
course_location
:
course
lesson_location
:
lesson
sl_location
:
sl
...
...
src/main/resources/application-prod.yml
View file @
a35cbcda
...
...
@@ -53,6 +53,16 @@ spring:
throw-exception-if-no-handler-found
:
true
resources
:
add-mappings
:
false
redis
:
host
:
106.2.3.134
port
:
7481
pool
:
max-idle
:
50
max-active
:
1000
min-idle
:
5
max-wait
:
-1
database
:
0
password
:
'
'
springfox
:
...
...
src/main/resources/architecture.md
View file @
a35cbcda
...
...
@@ -45,6 +45,46 @@
|images|(轮播图)
|default|
# 容器
## 容器编排
### html 工程
> 无node grunt 环境
镜像 httpd:2.4
1.
apache容器
2.
端口分配
[
12000-22000
]
### java 工程
> 包括maven 环境
镜像 maven:3.5-ibmjava-8
mysql
1.
jdk8的环境
2.
maven环境映射
## 容器存储
|eduLxc|
|userId|
|docker-compose.yml|
## redis
存储方案
~~~
~
{
lessonLxc:{
userid:{
"containerId":"",
"expiredMin":23,
"startDate":"2017-02-11 12:23:11",
"shutdownDate":"2017-02-11 12:53:11",
"sl":"",
"code":"1001"
}
}
}
~~~
~
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