mirror of
https://gitee.com/incloudcode/yexuejc-springboot.git
synced 2025-11-19 05:37:44 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ff9bb214c | |||
| bc3313861b | |||
|
|
2379043867 | ||
|
|
24a51a6a79 | ||
|
|
e8e3f9f2b1 | ||
|
|
686249f72b | ||
|
|
e3d8d21371 | ||
|
|
c542346564 |
24
README.md
24
README.md
@@ -8,37 +8,41 @@
|
||||
parent:版本封装<br/>
|
||||
base:功能封装
|
||||
|
||||
#### 引用
|
||||
>yexuejc.springboot.version=1.0.12
|
||||
#### 最新版本
|
||||
>yexuejc.springboot.version=1.1.0 <br>
|
||||
>yexuejc.base.version=1.1.9
|
||||
|
||||
pom.xml
|
||||
```
|
||||
<!--parent 引用-->
|
||||
<parent>
|
||||
<groupId>com.github.yexuejc.yexuejc-springboot</groupId>
|
||||
<groupId>com.yexuejc.springboot</groupId>
|
||||
<artifactId>yexuejc-springboot-parent</artifactId>
|
||||
<version>${yexuejc.springboot.version}</version>
|
||||
<version>最新版本</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!--base 引用-->
|
||||
<dependency>
|
||||
<groupId>com.github.yexuejc.yexuejc-springboot</groupId>
|
||||
<groupId>com.yexuejc.springboot</groupId>
|
||||
<artifactId>yexuejc-springboot-base</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
</dependency>
|
||||
<!--推荐使用-->
|
||||
<!--https://gitee.com/incloudcode/yexuejc-base.git-->
|
||||
<dependency>
|
||||
<groupId>com.github.yexuejc</groupId>
|
||||
<artifactId>yexuejc-base</artifactId>
|
||||
<version>${yexuejc.base.version}</version>
|
||||
<dependency>
|
||||
<groupId>com.yexuejc.base</groupId>
|
||||
<artifactId>yexuejc-base</artifactId>
|
||||
<version>${yexuejc.base.version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<id>yexuejc-nexus-public</id>
|
||||
<name>yexuejc-nexus-public</name>
|
||||
<url>https://nexus.yexuejc.club/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
```
|
||||
|
||||
39
UPDATE.md
39
UPDATE.md
@@ -1,6 +1,45 @@
|
||||
yexuejc-springboot 更新内容
|
||||
-------------------
|
||||
|
||||
#### version :1.1.0
|
||||
**time:2018-9-23 12:49:36** <br/>
|
||||
**branch:** master <br/>
|
||||
**关联工程:** <br/>
|
||||
```
|
||||
springboot-base:1.1.9
|
||||
spring-boot-starter-parent:1.5.15.RELEASE
|
||||
```
|
||||
**update:** <br/>
|
||||
1. 升级依赖
|
||||
2. 增加SSL证书忽略:默认关闭
|
||||
3. 本版本更新工具依赖[https://github.com/yexuejc/yexuejc-base.git](https://github.com/yexuejc/yexuejc-base.git)不向下兼容
|
||||
#
|
||||
|
||||
#### version :1.0.15
|
||||
**time:2018-9-3 19:29:39** <br/>
|
||||
**branch:** master <br/>
|
||||
**关联工程:** <br/>
|
||||
```
|
||||
springboot-base:1.1.8
|
||||
spring-boot-starter-parent:1.5.15.RELEASE
|
||||
```
|
||||
**update:** <br/>
|
||||
1. 升级依赖
|
||||
#
|
||||
|
||||
#### version :1.0.14
|
||||
**time:2018-8-25 14:31:05** <br/>
|
||||
**branch:** master <br/>
|
||||
**关联工程:** <br/>
|
||||
```
|
||||
springboot-base:1.1.7
|
||||
spring-boot-starter-parent:1.5.15.RELEASE
|
||||
```
|
||||
**update:** <br/>
|
||||
1. 升级依赖
|
||||
2. 优化拦截规则:增加通配符 /**
|
||||
#
|
||||
|
||||
#### version :1.0.13
|
||||
**time:2018-8-17 11:41:18** <br/>
|
||||
**branch:** master <br/>
|
||||
|
||||
47
pom.xml
47
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.yexuejc.springboot</groupId>
|
||||
<artifactId>yexuejc-springboot-parent</artifactId>
|
||||
<version>1.0.13</version>
|
||||
<version>1.1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
@@ -15,12 +15,12 @@
|
||||
<!-- spring boot父级,包含了统一版本管理,统一插件管理等 -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.12.RELEASE</version>
|
||||
<version>1.5.15.RELEASE</version>
|
||||
<!-- <relativePath/> lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<yexuejc.base.version>1.1.7</yexuejc.base.version>
|
||||
<yexuejc.base.version>1.1.9</yexuejc.base.version>
|
||||
<repos.yexuejc.url>https://nexus.yexuejc.club/repository/</repos.yexuejc.url>
|
||||
|
||||
<repos.aliyun.url>http://maven.aliyun.com/nexus/content/groups/public</repos.aliyun.url>
|
||||
@@ -29,39 +29,40 @@
|
||||
|
||||
<maven.compiler.verbose>true</maven.compiler.verbose>
|
||||
<java.version>1.8</java.version>
|
||||
<validation-api.version>1.1.0.Final</validation-api.version>
|
||||
<springfox-swagger2.version>2.2.2</springfox-swagger2.version>
|
||||
<mybatis-spring-boot-starter.version>1.2.0</mybatis-spring-boot-starter.version>
|
||||
<mybatis.version>3.4.2</mybatis.version>
|
||||
<validation-api.version>2.0.1.Final</validation-api.version>
|
||||
<springfox-swagger2.version>2.9.2</springfox-swagger2.version>
|
||||
<mybatis-spring-boot-starter.version>1.3.2</mybatis-spring-boot-starter.version>
|
||||
<mybatis.version>3.4.6</mybatis.version>
|
||||
|
||||
<jjwt.version>0.7.0</jjwt.version>
|
||||
<fastjson.version>1.1.46</fastjson.version>
|
||||
<commons-codec.version>1.10</commons-codec.version>
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
<fastjson.version>1.2.49</fastjson.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<!-- 阿里云相关 -->
|
||||
<aliyun-java-sdk-core.version>2.1.7</aliyun-java-sdk-core.version>
|
||||
<aliyun-java-sdk-sts.version>2.1.6</aliyun-java-sdk-sts.version>
|
||||
<aliyun-sdk-oss.version>2.8.1</aliyun-sdk-oss.version>
|
||||
<aliyun-java-sdk-dysmsapi.version>1.0.0</aliyun-java-sdk-dysmsapi.version>
|
||||
<aliyun-sdk-mns.version>1.1.8</aliyun-sdk-mns.version>
|
||||
<aliyun-java-sdk-core.version>4.0.8</aliyun-java-sdk-core.version>
|
||||
<aliyun-java-sdk-sts.version>3.0.0</aliyun-java-sdk-sts.version>
|
||||
<aliyun-sdk-oss.version>3.1.0</aliyun-sdk-oss.version>
|
||||
<aliyun-java-sdk-dysmsapi.version>1.1.0</aliyun-java-sdk-dysmsapi.version>
|
||||
<aliyun-sdk-mns.version>1.1.8.6</aliyun-sdk-mns.version>
|
||||
<!-- 支付宝相关 -->
|
||||
<alipay-sdk-java.version>20171023143759</alipay-sdk-java.version>
|
||||
<alipay-sdk-java.version>3.3.49.ALL</alipay-sdk-java.version>
|
||||
<!-- 微信相关 -->
|
||||
<WXPay-SDK-Java.version>0.0.4</WXPay-SDK-Java.version>
|
||||
<postgresql.version>9.4.1212</postgresql.version>
|
||||
<postgresql.version>42.2.4</postgresql.version>
|
||||
<!--thymeleaf 相关-->
|
||||
|
||||
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
|
||||
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
|
||||
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
|
||||
<thymeleaf-extras-springsecurity4.version>3.0.2.RELEASE</thymeleaf-extras-springsecurity4.version>
|
||||
</properties>
|
||||
<!-- 声明包版本 继承项目自引入 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!--基础包-->
|
||||
<dependency>
|
||||
<groupId>com.github.yexuejc</groupId>
|
||||
<artifactId>yexuejc-base</artifactId>
|
||||
<version>${yexuejc.base.version}</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.github.yexuejc</groupId>-->
|
||||
<!--<artifactId>yexuejc-base</artifactId>-->
|
||||
<!--<version>${yexuejc.base.version}</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.yexuejc.base</groupId>
|
||||
<artifactId>yexuejc-base</artifactId>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.yexuejc.springboot</groupId>
|
||||
<artifactId>yexuejc-springboot-parent</artifactId>
|
||||
<version>1.0.13</version>
|
||||
<version>1.1.0</version>
|
||||
<!-- 本地打包:使用相对关联路径 -->
|
||||
<!--<relativePath>../../yexuejc</relativePath>-->
|
||||
</parent>
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.yexuejc.springboot.base.filter.ValidationFilter;
|
||||
import com.yexuejc.springboot.base.filter.ValidationFilterProperties;
|
||||
import com.yexuejc.springboot.base.interceptor.LogInterceptor;
|
||||
import com.yexuejc.springboot.base.util.LogUtil;
|
||||
import com.yexuejc.springboot.base.util.SSLUtil;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -147,6 +148,15 @@ public class WebAutoConfiguration extends WebMvcConfigurerAdapter {
|
||||
return registration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
/**
|
||||
* 是否开启HTTPS(SSL)请求证书验证忽略:默认false
|
||||
*/
|
||||
@ConditionalOnProperty(name = "yexuejc.enable.ssl-ignore", matchIfMissing = false)
|
||||
public SSLUtil getSslUtil() {
|
||||
return new SSLUtil();
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局异常处理
|
||||
*/
|
||||
|
||||
@@ -7,11 +7,13 @@ import com.yexuejc.springboot.base.util.LogUtil;
|
||||
import com.yexuejc.springboot.base.util.NetUtil;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* 过滤器配置
|
||||
@@ -60,14 +62,35 @@ public class ValidationFilter implements Filter {
|
||||
}
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
if (RequestMethod.OPTIONS.name().equals(request.getMethod())) {
|
||||
//不拦截 OPTIONS 请求
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
String sp = request.getServletPath();
|
||||
if (properties.getType() == 0) {
|
||||
if (properties.getIgnored().contains(sp)) {
|
||||
AtomicBoolean b = new AtomicBoolean(false);
|
||||
properties.getIgnored().forEach(it -> {
|
||||
if (it.endsWith("/**") && sp.indexOf(it.substring(0, it.length() - 3)) > -1) {
|
||||
b.set(true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (b.get() || properties.getIgnored().contains(sp)) {
|
||||
//不拦截
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!properties.getIntercepts().contains(sp)) {
|
||||
AtomicBoolean b = new AtomicBoolean(true);
|
||||
properties.getIntercepts().forEach(it -> {
|
||||
if (it.endsWith("/**") && sp.indexOf(it.substring(0, it.length() - 3)) > -1) {
|
||||
b.set(false);
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (b.get() || !properties.getIntercepts().contains(sp)) {
|
||||
//不拦截
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.yexuejc.springboot.base.util;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* SSL证书忽略
|
||||
*
|
||||
* @ClassName: SSLUtil
|
||||
* @Description:
|
||||
* @author: maxf
|
||||
* @date: 2018/9/23 12:26:33
|
||||
*/
|
||||
public class SSLUtil {
|
||||
|
||||
|
||||
public SSLUtil() {
|
||||
disableSslVerification();
|
||||
}
|
||||
|
||||
private void disableSslVerification() {
|
||||
try {
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting trust manager
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
|
||||
// Create all-trusting host name verifier
|
||||
HostnameVerifier allHostsValid = new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting host verifier
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,4 +21,7 @@ yexuejc.http.encrypt.private-pwd=lgfishing2018
|
||||
spring.http.encoding.force=true
|
||||
spring.http.encoding.charset=UTF-8
|
||||
spring.http.encoding.enabled=true
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
|
||||
#是否开启HTTPS(SSL)请求证书验证忽略:默认false
|
||||
yexuejc.enable.ssl-ignore=true
|
||||
Reference in New Issue
Block a user