Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
7c8a9bd0
Commit
7c8a9bd0
authored
Jun 10, 2020
by
ZhengJie
Browse files
[代码完善](v2.5): 代码优化
parent
6c842236
Changes
5
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/utils/CallBack.java
View file @
7c8a9bd0
...
...
@@ -16,8 +16,6 @@
package
me.zhengjie.utils
;
import
java.io.IOException
;
/**
* @author: liaojinlong
* @date: 2020/6/9 17:02
...
...
@@ -36,8 +34,7 @@ public interface CallBack {
/**
* 本回调任务名称
*
* @return
* @return /
*/
default
String
getCallBackName
()
{
return
Thread
.
currentThread
().
getId
()
+
":"
+
this
.
getClass
().
getName
();
...
...
eladmin-common/src/main/java/me/zhengjie/utils/SpringContextHolder.java
View file @
7c8a9bd0
...
...
@@ -21,7 +21,6 @@ import org.springframework.beans.factory.DisposableBean;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.core.env.Environment
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -33,7 +32,7 @@ import java.util.List;
public
class
SpringContextHolder
implements
ApplicationContextAware
,
DisposableBean
{
private
static
ApplicationContext
applicationContext
=
null
;
private
static
List
<
CallBack
>
callBacks
=
new
ArrayList
<>();
private
static
final
List
<
CallBack
>
CALL_BACKS
=
new
ArrayList
<>();
private
static
boolean
addCallback
=
true
;
/**
...
...
@@ -44,7 +43,7 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
*/
public
synchronized
static
void
addCallBacks
(
CallBack
callBack
)
{
if
(
addCallback
)
{
SpringContextHolder
.
callBacks
.
add
(
callBack
);
SpringContextHolder
.
CALL_BACKS
.
add
(
callBack
);
}
else
{
log
.
warn
(
"CallBack:{} 已无法添加!立即执行"
,
callBack
.
getCallBackName
());
callBack
.
executor
();
...
...
@@ -74,14 +73,13 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
* @param property 属性key
* @param defaultValue 默认值
* @param requiredType 返回类型
* @return
* @return
/
*/
public
static
<
T
>
T
getProperties
(
String
property
,
T
defaultValue
,
Class
<
T
>
requiredType
)
{
T
result
=
defaultValue
;
try
{
result
=
getBean
(
Environment
.
class
).
getProperty
(
property
,
requiredType
);
}
catch
(
Exception
e
)
{
}
}
catch
(
Exception
ignored
)
{}
return
result
;
}
...
...
@@ -89,7 +87,7 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
* 获取SpringBoot 配置信息
*
* @param property 属性key
* @return
* @return
/
*/
public
static
String
getProperties
(
String
property
)
{
return
getProperties
(
property
,
null
,
String
.
class
);
...
...
@@ -100,7 +98,7 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
*
* @param property 属性key
* @param requiredType 返回类型
* @return
* @return
/
*/
public
static
<
T
>
T
getProperties
(
String
property
,
Class
<
T
>
requiredType
)
{
return
getProperties
(
property
,
null
,
requiredType
);
...
...
@@ -137,10 +135,10 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
}
SpringContextHolder
.
applicationContext
=
applicationContext
;
if
(
addCallback
)
{
for
(
CallBack
callBack
:
SpringContextHolder
.
callBacks
)
{
for
(
CallBack
callBack
:
SpringContextHolder
.
CALL_BACKS
)
{
callBack
.
executor
();
}
callBacks
.
clear
();
CALL_BACKS
.
clear
();
}
SpringContextHolder
.
addCallback
=
false
;
}
...
...
eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java
View file @
7c8a9bd0
...
...
@@ -42,6 +42,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
StringUtils
.
class
);
private
static
boolean
ipLocal
=
false
;
private
static
DbSearcher
searcher
=
null
;
private
static
final
char
SEPARATOR
=
'_'
;
private
static
final
String
UNKNOWN
=
"unknown"
;
static
{
SpringContextHolder
.
addCallBacks
(()
->
{
...
...
@@ -64,10 +66,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
});
}
private
static
final
char
SEPARATOR
=
'_'
;
private
static
final
String
UNKNOWN
=
"unknown"
;
/**
* 驼峰命名法工具
*
...
...
eladmin-system/src/main/resources/config/application-dev.yml
View file @
7c8a9bd0
...
...
@@ -70,14 +70,13 @@ jwt:
generator
:
enabled
:
true
#是否开启 swagger-ui
swagger
:
enabled
:
true
# IP 本地解析
ip
:
local-parsing
:
true
#是否开启 swagger-ui
swagger
:
enabled
:
true
# 文件存储路径
file
:
...
...
eladmin-system/src/main/resources/config/application-prod.yml
View file @
7c8a9bd0
...
...
@@ -68,6 +68,10 @@ jwt:
# 续期时间范围,默认 1小时,这里单位毫秒
renew
:
3600000
# IP 本地解析
ip
:
local-parsing
:
true
#是否允许生成代码,生产环境设置为false
generator
:
enabled
:
false
...
...
Write
Preview
Supports
Markdown
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