Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
ef8f5512
Commit
ef8f5512
authored
Aug 12, 2019
by
李秋伟
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request mall/arch/matrix!8
parents
72800bbd
63e8a798
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
97 additions
and
493 deletions
+97
-493
README.md
README.md
+30
-43
pom.xml
common-core/pom.xml
+1
-1
README.md
common-util/README.md
+39
-0
pom.xml
common-util/pom.xml
+1
-1
pom.xml
config-starter/pom.xml
+1
-1
pom.xml
elasticsearch-starter/pom.xml
+1
-1
pom.xml
logger-starter/pom.xml
+1
-1
pom.xml
logger-starter/secoo-log-starter/pom.xml
+1
-7
HttpClientUtils.java
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/utils/HttpClientUtils.java
+0
-416
pom.xml
logger-starter/secoo-log/pom.xml
+1
-1
pom.xml
mongodb-starter/pom.xml
+1
-1
pom.xml
monitor-starter/pom.xml
+1
-1
pom.xml
mybatis-starter/pom.xml
+1
-1
pom.xml
openfeign-starter/pom.xml
+1
-1
pom.xml
pom.xml
+14
-14
pom.xml
protocol-starter/pom.xml
+1
-1
pom.xml
redis-starter/pom.xml
+1
-1
pom.xml
rocketmq-starter/pom.xml
+1
-1
No files found.
README.md
View file @
ef8f5512
## 项目概述
简介
通用工具包主要整合了常用的工具类、通用对象、以及提供redis、mongodb、rocketMq等组件的统一分装,以便大家方便统一编码规范,有益于提高大家整体的开发效率。
Matrix (矩阵)是一套组件增强套件,包括redis、rocketmq等中间件以及提供通用util工具类,以利于提高代码的规范性,提高开发效率,对业务无侵入等
#
# 结构说明
#
组件
本项目结构如下:
-
[
common-core
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:提供通用bean,核心注解,定义通用业务异常。
-
[
common-util
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 提供BeanUtil,BeanChecker、CollectionUtil等工具类。
-
[
config-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 配置中心统一分装
-
[
redis-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:redis统一封装
-
[
mybatis-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:基于Mybatis-Plus进行二次包装
-
[
mongodb-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: mogodb统一封装
-
[
elasticsearch-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:访问elasticsearch统一封装
-
[
openfeign-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 对spring-cloud进行封装
-
[
monitor-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:提供支持dubbo等组件日志监控功能
-
[
logger-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 统一日志格式,增加应用透明性
-
[
protocol-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 服务发布模块提供http、dubbo协议增强,包括自定义filter、swagger支持等
```
# 开始
.
+-- common-core
+-- common-util
| +-- HttpUtil
+-- redis-starter
+-- mybaties-starter
+-- mongodb-starter
+-- elasticsearch-starter
+-- dubbo-starter
+-- web-starter
```
重要版本说明
说明:
-
添加依赖
-
Maven:需要在自己项目的pom.xml增加,以下配置。
**注意:Last Version为最新的版本号,详情查看[此处](http://gitlab.secoo.com:8090/mall/arch/matrix/tags )**
*
common-
\*
:通用依赖
```xml
*
\*
-starter:组件依赖
<parent>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix</artifactId>
<version>Last Version</version>
</parent>
```
# 期望
> 欢迎提出[issue](http://gitlab.secoo.com:8090/mall/arch/matrix/issues),帮助完善!
版本升级须知
当前开发版本 1.0.6-DEV-SNAPSHOT
1、rocketmq-starter 兼容Apollo
2、新增rocketmq 发送/接收,消息监听
正式版本
1.
0.4.RELEASE
1、增加logstater模块
2、修正多语言环境下zh的无法取到错误信息
3、增加rocketmq-starter组件
1.
0.3.RELEASE
1、增加monitor traceId监控模块
2、增加防灾冗余
3、优化文件结构
4、增加对controller返回null响应增强
1.
0.2.RELEASE
init code
# 关注
\ No newline at end of file
common-core/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
common-util/README.md
0 → 100644
View file @
ef8f5512
# 介绍
common-uti
# 组件
-
[
common-util
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 提供BeanUtil,BeanChecker、CollectionUtil等工具类。
-
[
config-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 配置中心统一分装
-
[
redis-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:redis统一封装
-
[
mybatis-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:基于Mybatis-Plus进行二次包装
-
[
mongodb-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: mogodb统一封装
-
[
elasticsearch-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:访问elasticsearch统一封装
-
[
openfeign-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 对spring-cloud进行封装
-
[
monitor-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
:提供支持dubbo等组件日志监控功能
-
[
logger-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 统一日志格式,增加应用透明性
-
[
protocol-starter
](
https://gitee.com/baomidou/mybatisplus-spring-mvc
)
: 服务发布模块提供http、dubbo协议增强,包括自定义filter、swagger支持等
# 开始
-
添加依赖
-
Maven:需要在自己项目的pom.xml增加,以下配置。
**注意:Last Version为最新的tag,点击[此处]查看。(http://gitlab.secoo.com:8090/mall/arch/matrix/tags )**
```xml
<parent>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix</artifactId>
<version>Last Version</version>
</parent>
```
# 期望
> 欢迎提出[issue](http://gitlab.secoo.com:8090/mall/arch/matrix/issues),帮助完善!
# 关注
\ No newline at end of file
common-util/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
config-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
elasticsearch-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
logger-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
logger-starter/secoo-log-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
logger-starter
</artifactId>
<artifactId>
logger-starter
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
@@ -31,17 +31,11 @@
...
@@ -31,17 +31,11 @@
<artifactId>
apollo-client
</artifactId>
<artifactId>
apollo-client
</artifactId>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-actuator-autoconfigure
</artifactId>
<artifactId>
spring-boot-actuator-autoconfigure
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.5
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<artifactId>
commons-io
</artifactId>
</dependency>
</dependency>
...
...
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/utils/HttpClientUtils.java
deleted
100644 → 0
View file @
72800bbd
package
com
.
secoo
.
mall
.
logs
.
utils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpPut
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
import
org.apache.http.conn.ssl.TrustSelfSignedStrategy
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.ssl.SSLContexts
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.StringUtils
;
import
javax.net.ssl.SSLContext
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URI
;
import
java.nio.charset.Charset
;
import
java.security.KeyManagementException
;
import
java.security.KeyStoreException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* httpClient封装
*
* @author QIANG
*/
public
class
HttpClientUtils
{
private
static
Logger
LOG
=
LoggerFactory
.
getLogger
(
HttpClientUtils
.
class
);
private
static
PoolingHttpClientConnectionManager
connMgr
;
private
static
RequestConfig
requestConfig
;
private
static
final
int
CONNECT_TIMEOUT
=
2000
;
private
static
final
int
SOCKET_TIMEOUT
=
2000
;
private
static
final
int
REQUEST_TIMEOUT
=
2000
;
private
static
final
String
CHARSET
=
"UTF-8"
;
static
{
// 设置连接池
connMgr
=
new
PoolingHttpClientConnectionManager
();
// 设置连接池大小
connMgr
.
setMaxTotal
(
300
);
connMgr
.
setDefaultMaxPerRoute
(
300
);
RequestConfig
.
Builder
configBuilder
=
RequestConfig
.
custom
();
// 请求超时时间
configBuilder
.
setConnectTimeout
(
CONNECT_TIMEOUT
);
// 连接不够时等待超时时间,不设置将阻塞线程
configBuilder
.
setConnectionRequestTimeout
(
REQUEST_TIMEOUT
);
// 等待数据超时时间
configBuilder
.
setSocketTimeout
(
SOCKET_TIMEOUT
);
LOG
.
debug
(
"Http参数设置,连接超时时间[{}],Socket超时时间[{}],请求超时时间[{}]"
,
CONNECT_TIMEOUT
,
SOCKET_TIMEOUT
);
requestConfig
=
configBuilder
.
build
();
}
/**
* 设置连接超时和请求超时
*
* @param connectTimeout
* @param socketTimeout
* @param connectionRequestTimeout
*/
public
static
void
setHttpParam
(
int
connectTimeout
,
int
socketTimeout
,
int
connectionRequestTimeout
)
{
RequestConfig
.
Builder
configBuilder
=
RequestConfig
.
custom
();
configBuilder
.
setConnectTimeout
(
connectTimeout
);
configBuilder
.
setSocketTimeout
(
socketTimeout
);
configBuilder
.
setConnectionRequestTimeout
(
connectionRequestTimeout
);
LOG
.
debug
(
"Http参数自定义设置,请求超时时间[{}],等待数据超时时间[{}],连接不够时等待超时时间[{}]"
,
connectTimeout
,
socketTimeout
,
connectionRequestTimeout
);
requestConfig
=
configBuilder
.
build
();
}
/**
* 发送 GET 请求(HTTP),不带输入数据
*
* @param url
* @return
* @throws Exception
*/
public
static
String
doGet
(
String
url
)
throws
Exception
{
return
doGet
(
url
,
new
HashMap
<>(
10
));
}
/**
* 发送 GET 请求(HTTP),K-V形式
*
* @param url
* @param params
* @return
* @throws Exception
*/
public
static
String
doGet
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
return
doGet
(
url
,
params
,
CHARSET
,
new
HashMap
<>(
16
));
}
public
static
String
doGet
(
String
url
,
Map
<
String
,
Object
>
params
,
String
charset
,
Map
<
String
,
String
>
headers
)
throws
Exception
{
String
result
=
null
;
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
info
(
"warn:doGet url is null or '' "
);
return
result
;
}
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>(
params
.
size
());
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
params
.
entrySet
())
{
pairList
.
add
(
new
BasicNameValuePair
(
entry
.
getKey
(),
entry
.
getValue
().
toString
()));
}
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setDefaultRequestConfig
(
requestConfig
)
.
setConnectionManager
(
connMgr
).
build
();
CloseableHttpResponse
response
=
null
;
InputStream
instream
=
null
;
try
{
URIBuilder
uriBuilder
=
new
URIBuilder
(
url
);
uriBuilder
.
setCharset
(
Charset
.
forName
(
StringUtils
.
isEmpty
(
charset
)
?
CHARSET
:
charset
));
uriBuilder
.
addParameters
(
pairList
);
URI
uri
=
uriBuilder
.
build
();
HttpGet
httpGet
=
new
HttpGet
(
uri
);
for
(
Map
.
Entry
<
String
,
String
>
entry
:
headers
.
entrySet
())
{
httpGet
.
setHeader
(
entry
.
getKey
(),
entry
.
getValue
());
}
response
=
httpclient
.
execute
(
httpGet
);
LOG
.
info
(
"doGet statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
instream
=
entity
.
getContent
();
result
=
IOUtils
.
toString
(
instream
,
charset
);
}
}
finally
{
if
(
null
!=
instream
)
{
instream
.
close
();
}
if
(
null
!=
response
)
{
response
.
close
();
}
LOG
.
info
(
"close instream response httpClient connection succ"
);
}
return
result
;
}
/**
* 发送 PUT 请求(HTTP),K-V形式
*
* @param url
* @param params
* @return
* @throws Exception
*/
public
static
String
doPut
(
String
url
,
Map
<
String
,
Object
>
params
,
String
charset
,
Map
<
String
,
String
>
headers
)
throws
Exception
{
String
result
=
null
;
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
info
(
"warn:doGet url is null or '' "
);
return
result
;
}
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>(
params
.
size
());
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
params
.
entrySet
())
{
pairList
.
add
(
new
BasicNameValuePair
(
entry
.
getKey
(),
entry
.
getValue
().
toString
()));
}
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setDefaultRequestConfig
(
requestConfig
)
.
setConnectionManager
(
connMgr
).
build
();
CloseableHttpResponse
response
=
null
;
InputStream
instream
=
null
;
try
{
URIBuilder
uriBuilder
=
new
URIBuilder
(
url
);
uriBuilder
.
setCharset
(
Charset
.
forName
(
StringUtils
.
isEmpty
(
charset
)
?
CHARSET
:
charset
));
uriBuilder
.
addParameters
(
pairList
);
URI
uri
=
uriBuilder
.
build
();
HttpPut
httpPut
=
new
HttpPut
(
uri
);
if
(
headers
!=
null
&&
headers
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
headers
.
entrySet
())
{
httpPut
.
setHeader
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
response
=
httpclient
.
execute
(
httpPut
);
LOG
.
info
(
"doGet statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
instream
=
entity
.
getContent
();
result
=
IOUtils
.
toString
(
instream
,
charset
);
}
}
finally
{
if
(
null
!=
instream
)
{
instream
.
close
();
}
if
(
null
!=
response
)
{
response
.
close
();
}
LOG
.
info
(
"close instream response httpClient connection succ"
);
}
return
result
;
}
/**
* 发送 POST 请求(HTTP),不带输入数据
*
* @param url
* @return
* @throws Exception
*/
public
static
String
doPost
(
String
url
)
throws
Exception
{
return
doPost
(
url
,
new
HashMap
<>(
16
));
}
/**
* 发送 POST 请求(HTTP),K-V形式
*
* @param url API接口URL
* @param params 参数map
* @return
* @throws Exception
*/
public
static
String
doPost
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
info
(
"warn:doPost url is null or '' "
);
return
null
;
}
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>(
params
.
size
());
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
params
.
entrySet
())
{
pairList
.
add
(
new
BasicNameValuePair
(
entry
.
getKey
(),
entry
.
getValue
().
toString
()));
}
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
pairList
,
Charset
.
forName
(
CHARSET
)));
return
send
(
httpPost
,
false
);
}
/**
* 发送 POST 请求(HTTP),xml
*
* @param url API接口URL
* @param xml xml 参数
* @return
* @throws Exception
*/
public
static
String
doPost
(
String
url
,
String
xml
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
info
(
"warn:doPost url is null or '' "
);
return
null
;
}
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setEntity
(
new
StringEntity
(
xml
,
"GBK"
));
return
send
(
httpPost
,
false
);
}
/**
* 发送 POST 请求(HTTP),JSON形式
*
* @param url
* @param json json对象
* @return
* @throws Exception
*/
public
static
String
doPost
(
String
url
,
Object
json
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
error
(
"warn:doPostByJson url is null or '' "
);
return
null
;
}
HttpPost
httpPost
=
new
HttpPost
(
url
);
StringEntity
stringEntity
=
new
StringEntity
(
json
.
toString
(),
CHARSET
);
stringEntity
.
setContentType
(
"application/json"
);
httpPost
.
setEntity
(
stringEntity
);
return
send
(
httpPost
,
false
);
}
public
static
String
doPost
(
String
url
,
StringEntity
entity
,
Map
<
String
,
String
>
headers
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
error
(
"warn:doPostByJson url is null or '' "
);
return
null
;
}
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setEntity
(
entity
);
headers
.
forEach
((
k
,
v
)
->
{
httpPost
.
setHeader
(
k
,
v
);
});
return
send
(
httpPost
,
false
);
}
/**
* 发送 SSL POST 请求(HTTPS),K-V形式
*
* @param apiUrl API接口URL
* @param params 参数map
* @return
* @throws Exception
*/
public
static
String
doPostSSL
(
String
apiUrl
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
apiUrl
))
{
LOG
.
info
(
"warn:doPostSSL url is null or '' "
);
return
null
;
}
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>(
params
.
size
());
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
params
.
entrySet
())
{
NameValuePair
pair
=
new
BasicNameValuePair
(
entry
.
getKey
(),
entry
.
getValue
().
toString
());
pairList
.
add
(
pair
);
}
HttpPost
httpPost
=
new
HttpPost
(
apiUrl
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
pairList
,
Charset
.
forName
(
"utf-8"
)));
return
send
(
httpPost
,
true
);
}
/**
* 发送 SSL POST 请求(HTTPS),JSON形式
*
* @param apiUrl API接口URL
* @param json JSON对象
* @return
* @throws Exception
*/
public
static
String
doPostSSL
(
String
apiUrl
,
Object
json
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
apiUrl
))
{
LOG
.
info
(
"warn:doPostSSL By Json url is null or '' "
);
return
null
;
}
StringEntity
stringEntity
=
new
StringEntity
(
json
.
toString
(),
CHARSET
);
HttpPost
httpPost
=
new
HttpPost
(
apiUrl
);
httpPost
.
setEntity
(
stringEntity
);
stringEntity
.
setContentEncoding
(
CHARSET
);
stringEntity
.
setContentType
(
"application/json"
);
return
send
(
httpPost
,
true
);
}
/**
* 发送Post请求
*
* @param httpPost
* @return
* @throws IOException
* @throws ClientProtocolException
* @throws KeyStoreException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
private
static
String
send
(
HttpPost
httpPost
,
boolean
isSsl
)
throws
ClientProtocolException
,
IOException
,
KeyManagementException
,
NoSuchAlgorithmException
,
KeyStoreException
{
CloseableHttpClient
httpClient
=
null
;
InputStream
instream
=
null
;
String
result
=
null
;
CloseableHttpResponse
response
=
null
;
try
{
if
(
isSsl
)
{
SSLContext
sslcontext
=
SSLContexts
.
custom
().
loadTrustMaterial
(
null
,
new
TrustSelfSignedStrategy
())
.
build
();
SSLConnectionSocketFactory
sslsf
=
new
SSLConnectionSocketFactory
(
sslcontext
);
httpClient
=
HttpClients
.
custom
().
setConnectionManager
(
connMgr
).
setSSLSocketFactory
(
sslsf
)
.
setDefaultRequestConfig
(
requestConfig
).
build
();
}
else
{
httpClient
=
HttpClients
.
custom
().
setDefaultRequestConfig
(
requestConfig
).
setConnectionManager
(
connMgr
)
.
build
();
}
response
=
httpClient
.
execute
(
httpPost
);
LOG
.
info
(
"doPost statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
instream
=
entity
.
getContent
();
result
=
IOUtils
.
toString
(
instream
,
CHARSET
);
LOG
.
info
(
"doPost Result:{}"
,
result
);
}
}
finally
{
if
(
null
!=
instream
)
{
instream
.
close
();
}
if
(
null
!=
response
)
{
response
.
close
();
}
LOG
.
info
(
"close instream response httpClient connection succ"
);
}
return
result
;
}
}
logger-starter/secoo-log/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
logger-starter
</artifactId>
<artifactId>
logger-starter
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
mongodb-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
monitor-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
mybatis-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
openfeign-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
pom.xml
View file @
ef8f5512
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
<packaging>
pom
</packaging>
<packaging>
pom
</packaging>
...
@@ -45,67 +45,67 @@
...
@@ -45,67 +45,67 @@
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
secoo-log-starter
</artifactId>
<artifactId>
secoo-log-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
secoo-log
</artifactId>
<artifactId>
secoo-log
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
monitor-starter
</artifactId>
<artifactId>
monitor-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-core
</artifactId>
<artifactId>
common-core
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
config-starter
</artifactId>
<artifactId>
config-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-util
</artifactId>
<artifactId>
common-util
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
redis-starter
</artifactId>
<artifactId>
redis-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
mybatis-starter
</artifactId>
<artifactId>
mybatis-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
mongodb-starter
</artifactId>
<artifactId>
mongodb-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
elasticsearch-starter
</artifactId>
<artifactId>
elasticsearch-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
protocol-starter
</artifactId>
<artifactId>
protocol-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
rocketmq-starter
</artifactId>
<artifactId>
rocketmq-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
openfeign-starter
</artifactId>
<artifactId>
openfeign-starter
</artifactId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
protocol-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
redis-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
rocketmq-starter/pom.xml
View file @
ef8f5512
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.
11.RELEASE
</version>
<version>
1.0.
0-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
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