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
58a5d968
Commit
58a5d968
authored
Dec 05, 2019
by
qiuweili123
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GX-1861 appsecurity项目初始化
parent
915cc5f0
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
329 additions
and
236 deletions
+329
-236
pom.xml
common-core/pom.xml
+1
-1
MatrixUrlClassLoader.java
common-core/src/main/java/com/secoo/mall/common/core/classloader/MatrixUrlClassLoader.java
+26
-2
pom.xml
common-util/pom.xml
+1
-1
IpUtil.java
common-util/src/main/java/com/secoo/mall/common/util/net/IpUtil.java
+71
-0
WebUtil.java
common-util/src/main/java/com/secoo/mall/common/util/web/WebUtil.java
+0
-44
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
matrix-datasource/matrix-datasource-core/pom.xml
+68
-0
pom.xml
matrix-datasource/pom.xml
+62
-0
pom.xml
matrix-mybatis/matrix-mybatis-core/pom.xml
+2
-14
MatrixDataSource.java
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/bean/MatrixDataSource.java
+0
-7
DataSourceType.java
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/constants/DataSourceType.java
+0
-5
Encryptor.java
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/encryptor/Encryptor.java
+0
-19
EncryptorFactory.java
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/encryptor/EncryptorFactory.java
+0
-32
pom.xml
matrix-mybatis/matrix-mybatis-starter/pom.xml
+0
-4
AopTransaction.java
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/aop/AopTransaction.java
+2
-2
MybatisConfig.java
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/config/MybatisConfig.java
+9
-6
MasterDataSourceProperties.java
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/autoconfigure/MasterDataSourceProperties.java
+0
-10
MatrixDataSouceAutoConfiguration.java
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/autoconfigure/MatrixDataSouceAutoConfiguration.java
+38
-26
MatrixDefaultDataSourceProperties.java
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/autoconfigure/MatrixDefaultDataSourceProperties.java
+10
-0
MybatisApplicationContextInitializer.java
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/initializer/MybatisApplicationContextInitializer.java
+5
-24
MybatisApplicationRunListener.java
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/listener/MybatisApplicationRunListener.java
+3
-3
spring.factories
matrix-mybatis/matrix-mybatis-starter/src/main/resources/META-INF/spring.factories
+3
-5
application.yml
matrix-mybatis/matrix-mybatis-starter/src/test/resources/application.yml
+4
-2
pom.xml
matrix-mybatis/pom.xml
+14
-19
pom.xml
mongodb-starter/pom.xml
+1
-1
pom.xml
monitor-starter/pom.xml
+1
-1
pom.xml
openfeign-starter/pom.xml
+1
-1
pom.xml
pom.xml
+1
-1
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.
common-core/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
common-core/src/main/java/com/secoo/mall/common/core/classloader/MatrixUrlClassLoader.java
View file @
58a5d968
...
...
@@ -2,13 +2,14 @@ package com.secoo.mall.common.core.classloader;
import
com.secoo.mall.common.core.exception.SystemInternalException
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
public
class
MatrixUrlClassLoader
extends
URLClassLoader
{
private
volatile
static
MatrixUrlClassLoader
instance
;
private
static
ClassLoader
classLoader
=
Thread
.
currentThread
().
getContex
tClassLoader
();
private
static
ClassLoader
classLoader
=
MatrixUrlClassLoader
.
class
.
ge
tClassLoader
();
private
static
final
Method
addUrl
;
//并行加载classLoader
...
...
@@ -43,12 +44,35 @@ public class MatrixUrlClassLoader extends URLClassLoader {
return
instance
;
}
public
void
loadByUrl
(
URL
url
)
{
public
void
loadByUrl
(
String
urlStr
)
{
try
{
URL
url
=
new
URL
(
urlStr
);
addUrl
.
invoke
(
classLoader
,
url
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
SystemInternalException
();
}
}
public
<
T
>
T
loadClassByFullName
(
String
fullClassName
,
Class
<
T
>
clazz
)
{
return
loadClassByFullName
(
fullClassName
,
clazz
,
null
,
null
);
}
public
<
T
>
T
loadClassByFullName
(
String
fullClassName
,
Class
<
T
>
clazz
,
Class
[]
args
,
Object
[]
params
)
{
try
{
Class
<?>
tClass
=
classLoader
.
loadClass
(
fullClassName
);
Class
<?
extends
T
>
factClass
=
tClass
.
asSubclass
(
clazz
);
//生成实际类
//有参构造函数调用
if
(
args
!=
null
&&
args
.
length
>
0
)
{
Constructor
<?
extends
T
>
constructor
=
factClass
.
getDeclaredConstructor
(
args
);
return
constructor
.
newInstance
(
params
);
}
//默认构造函数调用
return
factClass
.
newInstance
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
SystemInternalException
();
}
}
}
common-util/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
common-util/src/main/java/com/secoo/mall/common/util/net/IpUtil.java
0 → 100644
View file @
58a5d968
package
com
.
secoo
.
mall
.
common
.
util
.
net
;
import
org.springframework.util.StringUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
public
class
IpUtil
{
private
static
String
[]
headers
=
new
String
[]{
"Cdn-Src-Ip"
,
"X-Real-IP"
,
"X-Forwarded-For"
,
"Proxy-Client-IP"
,
"WL-Proxy-Client-IP"
,
"HTTP_CLIENT_IP"
,
"HTTP_X_FORWARDED_FOR"
};
private
static
String
localIP
=
"127.0.0.1"
;
/**
* 获取请求客户端IP地址,支持代理服务器
*
* @param request {@link HttpServletRequest} 对象
* @return IP地址
*/
public
static
String
getRemoteAddr
(
HttpServletRequest
request
)
{
// 1、获取客户端IP地址,支持代理服务器
String
remoteAddr
=
null
;
for
(
String
header
:
headers
)
{
remoteAddr
=
request
.
getHeader
(
header
);
if
(
StringUtils
.
hasText
(
remoteAddr
)
&&
!
remoteAddr
.
equals
(
"unknown"
))
{
break
;
}
}
// 2、没有取得特定标记的值
if
(!
StringUtils
.
hasText
(
remoteAddr
))
{
remoteAddr
=
request
.
getRemoteAddr
();
}
// 3、判断是否localhost访问
if
(
remoteAddr
.
equals
(
"localhost"
))
{
remoteAddr
=
localIP
;
}
return
remoteAddr
;
}
/**
* 获得请求的客户端信息【ip,port,name】
*
* @param request {@link HttpServletRequest} 对象
* @return 客户端信息[ip, port, name]
*/
public
static
String
[]
getRemoteInfo
(
HttpServletRequest
request
)
{
if
(
request
==
null
)
{
return
new
String
[]{
""
,
""
,
""
};
}
return
new
String
[]{
getRemoteAddr
(
request
),
request
.
getRemotePort
()
+
""
,
request
.
getRemoteHost
()};
}
public
static
String
getHostIp
()
{
try
{
return
InetAddress
.
getLocalHost
().
getHostAddress
();
}
catch
(
UnknownHostException
e
)
{
}
return
"127.0.0.1"
;
}
public
static
String
getHostName
()
{
try
{
return
InetAddress
.
getLocalHost
().
getHostName
();
}
catch
(
UnknownHostException
e
)
{
}
return
"未知"
;
}
}
common-util/src/main/java/com/secoo/mall/common/util/web/WebUtil.java
View file @
58a5d968
package
com
.
secoo
.
mall
.
common
.
util
.
web
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
...
...
@@ -12,8 +11,6 @@ import javax.servlet.http.HttpSession;
public
class
WebUtil
extends
WebUtils
{
private
static
String
sessionUser
=
"sessionUser"
;
private
static
String
[]
headers
=
new
String
[]{
"Cdn-Src-Ip"
,
"X-Real-IP"
,
"X-Forwarded-For"
,
"Proxy-Client-IP"
,
"WL-Proxy-Client-IP"
,
"HTTP_CLIENT_IP"
,
"HTTP_X_FORWARDED_FOR"
};
private
static
String
localIP
=
"127.0.0.1"
;
public
static
String
getParameter
(
String
name
)
{
return
getRequest
().
getParameter
(
name
);
...
...
@@ -57,46 +54,5 @@ public class WebUtil extends WebUtils {
}
/**
* 获取请求客户端IP地址,支持代理服务器
*
* @param request {@link HttpServletRequest} 对象
* @return IP地址
*/
public
static
String
getRemoteAddr
(
HttpServletRequest
request
)
{
// 1、获取客户端IP地址,支持代理服务器
String
remoteAddr
=
null
;
for
(
String
header
:
headers
)
{
remoteAddr
=
request
.
getHeader
(
header
);
if
(
StringUtils
.
hasText
(
remoteAddr
)
&&
!
remoteAddr
.
equals
(
"unknown"
))
{
break
;
}
}
// 2、没有取得特定标记的值
if
(!
StringUtils
.
hasText
(
remoteAddr
))
{
remoteAddr
=
request
.
getRemoteAddr
();
}
// 3、判断是否localhost访问
if
(
remoteAddr
.
equals
(
"localhost"
))
{
remoteAddr
=
localIP
;
}
return
remoteAddr
;
}
/**
* 获得请求的客户端信息【ip,port,name】
*
* @param request {@link HttpServletRequest} 对象
* @return 客户端信息[ip, port, name]
*/
public
static
String
[]
getRemoteInfo
(
HttpServletRequest
request
)
{
if
(
request
==
null
)
{
return
new
String
[]{
""
,
""
,
""
};
}
return
new
String
[]{
getRemoteAddr
(
request
),
request
.
getRemotePort
()
+
""
,
request
.
getRemoteHost
()};
}
}
config-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
elasticsearch-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
logger-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-datasource/matrix-datasource-core/pom.xml
0 → 100644
View file @
58a5d968
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-datasource
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-datasource-core
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-crypto
</artifactId>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjweaver
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
app-security-algorithm
</artifactId>
</dependency>
<!--所依赖的数据源-->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<dependency>
<groupId>
com.zaxxer
</groupId>
<artifactId>
HikariCP
</artifactId>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
org.javassist
</groupId>
<artifactId>
javassist
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-datasource/pom.xml
0 → 100644
View file @
58a5d968
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-datasource
</artifactId>
<packaging>
pom
</packaging>
<modules>
<module>
matrix-datasource-core
</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.zaxxer
</groupId>
<artifactId>
HikariCP
</artifactId>
<version>
3.2.0
</version>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
1.1.20
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.1.20
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
app-security-algorithm
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.47
</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-util
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-mybatis/matrix-mybatis-core/pom.xml
View file @
58a5d968
...
...
@@ -18,20 +18,8 @@
<version>
${mybatis-plus.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-crypto
</artifactId>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
org.javassist
</groupId>
<artifactId>
javassist
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-datasource-core
</artifactId>
</dependency>
</dependencies>
...
...
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/bean/MatrixDataSource.java
deleted
100644 → 0
View file @
915cc5f0
package
com
.
secoo
.
mall
.
mybatis
.
bean
;
import
com.secoo.mall.mybatis.config.MatrixDataSourceConfig
;
public
class
MatrixDataSource
extends
MatrixDataSourceConfig
{
}
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/constants/DataSourceType.java
deleted
100644 → 0
View file @
915cc5f0
package
com
.
secoo
.
mall
.
mybatis
.
constants
;
public
enum
DataSourceType
{
DRUID
,
HIKARI
;
}
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/encryptor/Encryptor.java
deleted
100644 → 0
View file @
915cc5f0
package
com
.
secoo
.
mall
.
mybatis
.
encryptor
;
/**
* Encryptor
* @param <T>
*/
public
interface
Encryptor
<
T
>
{
/**
* Encrypt the raw value.
*/
T
encrypt
(
T
value
);
/**
* Decrypt the encrypted value
*/
T
decrypt
(
T
encryptedValue
);
}
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/encryptor/EncryptorFactory.java
deleted
100644 → 0
View file @
915cc5f0
package
com
.
secoo
.
mall
.
mybatis
.
encryptor
;
public
class
EncryptorFactory
{
private
static
EncryptorFactory
instance
;
private
Encryptor
encryptor
;
private
EncryptorFactory
()
{
}
public
static
EncryptorFactory
getInstance
()
{
if
(
instance
==
null
)
{
synchronized
(
EncryptorFactory
.
class
)
{
if
(
instance
==
null
)
instance
=
new
EncryptorFactory
();
}
}
return
instance
;
}
public
Encryptor
getEncryptor
()
{
return
null
;
}
}
matrix-mybatis/matrix-mybatis-starter/pom.xml
View file @
58a5d968
...
...
@@ -21,10 +21,6 @@
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
...
...
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/aop/AopTransaction.java
View file @
58a5d968
...
...
@@ -15,7 +15,7 @@ import javax.annotation.Resource;
@Aspect
@Component
@ConditionalOnProperty
(
value
=
"matrix.aop-transaction.enabled"
,
havingValue
=
"true"
)
@ConditionalOnProperty
(
value
=
"matrix.aop-transaction.enabled"
,
havingValue
=
"true"
)
public
class
AopTransaction
{
@Resource
private
PlatformTransactionManager
transactionManager
;
...
...
@@ -29,7 +29,7 @@ public class AopTransaction {
public
void
createPointCut
()
{
}
/**
* 更新切入点
*/
...
...
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/config/MybatisConfig.java
View file @
58a5d968
package
com
.
secoo
.
mall
.
mybatis
.
config
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties
;
import
com.baomidou.mybatisplus.core.MybatisConfiguration
;
import
com.baomidou.mybatisplus.core.config.GlobalConfig
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
...
...
@@ -11,14 +11,15 @@ import com.baomidou.mybatisplus.extension.toolkit.PackageHelper;
import
com.secoo.mall.common.constant.CommonConstant
;
import
com.secoo.mall.common.util.string.StringUtil
;
import
com.secoo.mall.mybatis.handler.FillDefaultValueHandler
;
import
com.secoo.mall.mybatis.spring.boot.autoconfigure.MatrixDataSouceAutoConfiguration
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.type.JdbcType
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
javax.annotation.Resource
;
import
javax.sql.DataSource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -26,18 +27,20 @@ import java.util.stream.Stream;
@Configuration
@Import
(
MatrixDataSouceAutoConfiguration
.
class
)
public
class
MybatisConfig
{
@Value
(
"${spring.profiles.active}"
)
private
String
profile
;
@Resource
private
MybatisPlusProperties
mybatisPlusProperties
;
/*
@Resource
private MybatisPlusProperties mybatisPlusProperties;
*/
@Bean
(
"mybatisSqlSession"
)
@Bean
public
SqlSessionFactory
sqlSessionFactory
(
DataSource
dataSource
,
GlobalConfig
globalConfig
)
throws
Exception
{
MybatisSqlSessionFactoryBean
sqlSessionFactory
=
new
MybatisSqlSessionFactoryBean
();
String
[]
aliasesPackages
=
PackageHelper
.
convertTypeAliasesPackage
(
"com.secoo.mall.**.bean.domain"
);
globalConfig
.
getDbConfig
().
setDbType
(
DbType
.
MYSQL
);
List
<
String
>
list
=
Stream
.
of
(
aliasesPackages
).
collect
(
Collectors
.
toList
());
/*文件包别名加载*/
sqlSessionFactory
.
setTypeAliasesPackage
(
StringUtil
.
join
(
list
,
","
));
...
...
@@ -68,7 +71,7 @@ public class MybatisConfig {
return
sqlSessionFactory
.
getObject
();
}
@Bean
(
"globalConfig"
)
@Bean
public
GlobalConfig
globalConfig
()
{
GlobalConfig
conf
=
new
GlobalConfig
();
GlobalConfig
.
DbConfig
dbConfig
=
new
GlobalConfig
.
DbConfig
();
...
...
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/autoconfigure/MasterDataSourceProperties.java
deleted
100644 → 0
View file @
915cc5f0
package
com
.
secoo
.
mall
.
mybatis
.
spring
.
boot
.
autoconfigure
;
import
com.secoo.mall.mybatis.config.MatrixDataSourceConfig
;
import
lombok.Data
;
//@ConfigurationProperties(prefix = MasterDataSourceProperties.PREFIX)
@Data
public
class
MasterDataSourceProperties
extends
MatrixDataSourceConfig
{
public
static
final
String
PREFIX
=
MatrixDataSourceConfig
.
PREFIX
+
".master"
;
}
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/autoconfigure/MatrixDataSouceAutoConfiguration.java
View file @
58a5d968
package
com
.
secoo
.
mall
.
mybatis
.
spring
.
boot
.
autoconfigure
;
import
com.
alibaba.druid.pool.DruidDataSource
;
import
com.
alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigur
e
;
import
com.
alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties
;
import
com.
alibaba.druid.spring.boot.autoconfigure.stat.DruidFilterConfiguration
;
import
com.
alibaba.druid.spring.boot.autoconfigure.stat.DruidSpringAopConfiguration
;
import
com.
alibaba.druid.spring.boot.autoconfigure.stat.DruidStatViewServletConfiguration
;
import
com.alibaba.druid.spring.boot.autoconfigure.stat.DruidWebStatFilterConfiguration
;
import
com.
ctrip.framework.apollo.spring.boot.ApolloAutoConfiguration
;
import
com.
secoo.mall.datasource.bean.MatrixDataSourc
e
;
import
com.
secoo.mall.datasource.bean.MatrixDynamicDataSource
;
import
com.
secoo.mall.datasource.provider.ApolloDataSourceProvider
;
import
com.
secoo.mall.datasource.provider.DataSourceProvider
;
import
com.
secoo.mall.datasource.util.SysUtil
;
import
lombok.Setter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
javax.sql.DataSource
;
/*
@Configuration
@ConditionalOnClass(com.alibaba.druid.pool.DruidDataSource.class)
@AutoConfigureBefore(name = {
"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration",
"com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration"
})
@ConditionalOnProperty(prefix = MatrixDataSourceProperties.PREFIX,name = "type", havingValue = "druid", matchIfMissing = false)
@EnableConfigurationProperties({MatrixDataSourceProperties.class,DruidStatProperties.class, DataSourceProperties.class})
@Import({DruidSpringAopConfiguration.class,
DruidStatViewServletConfiguration.class,
DruidWebStatFilterConfiguration.class,
DruidFilterConfiguration.class})*/
@ConditionalOnClass
(
MatrixDataSource
.
class
)
@AutoConfigureBefore
(
DataSourceAutoConfiguration
.
class
)
@AutoConfigureAfter
(
ApolloAutoConfiguration
.
class
)
@EnableConfigurationProperties
({
MatrixDefaultDataSourceProperties
.
class
})
@Slf4j
public
class
MatrixDataSouceAutoConfiguration
extends
DruidDataSourceAutoConfigure
{
public
class
MatrixDataSouceAutoConfiguration
{
@Setter
private
MatrixDefaultDataSourceProperties
matrixDefaultDataSourceProperties
;
public
MatrixDataSouceAutoConfiguration
(){
log
.
info
(
"init MatrixDataSouce
"
);
public
MatrixDataSouceAutoConfiguration
()
{
log
.
info
(
"Init MatrixDataSouceAutoConfiguration
"
);
}
@Value
(
"${config.app.security.accessToken}"
)
private
String
acccessToken
;
@Bean
@ConditionalOnMissingBean
(
DataSourceProvider
.
class
)
public
DataSourceProvider
dataSourceProvider
()
{
SysUtil
.
setProperty
(
"accessToken"
,
acccessToken
);
return
new
ApolloDataSourceProvider
();
}
/**
* 如果没有声明,则使用默认的
*
* @return
*/
@Bean
@ConditionalOnMissingBean
(
DataSource
.
class
)
public
DataSource
dataSource
()
{
return
new
MatrixDynamicDataSource
(
"default"
);
}
}
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/autoconfigure/MatrixDefaultDataSourceProperties.java
0 → 100644
View file @
58a5d968
package
com
.
secoo
.
mall
.
mybatis
.
spring
.
boot
.
autoconfigure
;
import
com.secoo.mall.datasource.properties.MatrixDataSourceProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
@ConfigurationProperties
(
prefix
=
MatrixDefaultDataSourceProperties
.
PREFIX
)
public
class
MatrixDefaultDataSourceProperties
extends
MatrixDataSourceProperties
{
public
static
final
String
PREFIX
=
MatrixDataSourceProperties
.
PREFIX
+
".default"
;
}
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/initializer/MybatisApplicationContextInitializer.java
View file @
58a5d968
package
com
.
secoo
.
mall
.
mybatis
.
spring
.
boot
.
initializer
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.SystemUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.env.EnvironmentPostProcessor
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.PropertiesPropertySource
;
import
org.springframework.util.ResourceUtils
;
import
sun.rmi.runtime.Log
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.util.Properties
;
import
java.util.Set
;
public
class
MybatisApplicationContextInitializer
extends
ApolloApplicationContextInitializer
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
MybatisApplicationContextInitializer
.
class
);
public
class
MybatisApplicationContextInitializer
extends
ApolloApplicationContextInitializer
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
MybatisApplicationContextInitializer
.
class
);
public
static
String
MYBATIS_ENCRYPT_PWD
=
"mybats.encryptor.pwd"
;
public
static
String
MYBATIS_ENCRYPT_SALT
=
"mybats.encryptor.salt"
;
public
static
String
MYBATIS_ENCRYPT_PWD
=
"mybatis.encryptor.pwd"
;
public
static
String
MYBATIS_ENCRYPT_SALT
=
"mybatis.encryptor.salt"
;
public
static
String
ENCRYPT_FILE_NAME
=
"encryptor.properties"
;
@Override
...
...
@@ -40,7 +21,7 @@ public class MybatisApplicationContextInitializer extends ApolloApplicationCon
}
// public static Integer ORDER = ApolloApplicationContextInitializer.DEFAULT_ORDER + 100;
// public static Integer ORDER = ApolloApplicationContextInitializer.DEFAULT_ORDER + 100;
...
...
matrix-mybatis/matrix-mybatis-starter/src/main/java/com/secoo/mall/mybatis/spring/boot/listener/MybatisApplicationRunListener.java
View file @
58a5d968
...
...
@@ -55,7 +55,7 @@ public class MybatisApplicationRunListener implements SpringApplicationRunListen
//从文件加载
initFileConfig
(
properties
);
//解密配置
// initApolloConfig(properties);
// initApolloConfig(properties);
environment
.
getPropertySources
();
environment
.
getPropertySources
().
addFirst
((
new
PropertiesPropertySource
(
"matrixProperties"
,
properties
)));
...
...
@@ -104,7 +104,7 @@ public class MybatisApplicationRunListener implements SpringApplicationRunListen
}
private
void
initFileConfig
(
Properties
properties
)
{
if
(!
properties
.
containsKey
(
MYBATIS_ENCRYPT_PWD
))
{
if
(!
properties
.
containsKey
(
MYBATIS_ENCRYPT_PWD
))
{
try
{
File
file
=
ResourceUtils
.
getFile
(
SystemUtils
.
USER_HOME
+
File
.
separator
+
ENCRYPT_FILE_NAME
);
if
(!
file
.
exists
())
{
...
...
@@ -124,7 +124,7 @@ public class MybatisApplicationRunListener implements SpringApplicationRunListen
/**
* 解密相关的配置
*/
private
void
initApolloConfig
(
Properties
properties
){
private
void
initApolloConfig
(
Properties
properties
)
{
Config
appConfig
=
ConfigService
.
getConfig
(
"db.config"
);
Set
<
String
>
propertyNames
=
appConfig
.
getPropertyNames
();
...
...
matrix-mybatis/matrix-mybatis-starter/src/main/resources/META-INF/spring.factories
View file @
58a5d968
# Auto Configure
#org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
#com.secoo.mall.mybatis.spring.boot.autoconfigure.MatrixDataSouceAutoConfiguration
org.springframework.context.ApplicationContextInitializer=\
com.secoo.mall.mybatis.spring.boot.initializer.MybatisApplicationContextInitializer
\ No newline at end of file
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.secoo.mall.mybatis.spring.boot.autoconfigure.MatrixDataSouceAutoConfiguration
\ No newline at end of file
matrix-mybatis/matrix-mybatis-starter/src/test/resources/application.yml
View file @
58a5d968
mat
\ No newline at end of file
spring
:
datasource
:
matrix
:
type
:
druid
matrix-mybatis/pom.xml
View file @
58a5d968
...
...
@@ -38,27 +38,21 @@
<version>
${mybatis-plus.version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
1.1.20
</version>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.47
</version>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-datasource-core
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-util
</artifactId>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-util
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
mongodb-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
monitor-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
openfeign-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
pom.xml
View file @
58a5d968
...
...
@@ -23,6 +23,7 @@
<module>
config-starter
</module>
<module>
protocol-starter
</module>
<module>
logger-starter
</module>
<module>
matrix-datasource
</module>
</modules>
...
...
@@ -30,7 +31,6 @@
<java.version>
1.8
</java.version>
<dubbo-starter.version>
2.7.1
</dubbo-starter.version>
<dubbo.version>
2.7.2
</dubbo.version>
<matrix.version>
1.0.1-DEV-SNAPSHOT
</matrix.version>
</properties>
...
...
protocol-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
redis-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
rocketmq-starter/pom.xml
View file @
58a5d968
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.
1.8.RELEASE
</version>
<version>
1.
0.0-SNAPSHOT
</version>
</parent>
<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