升级SpringBoot 2.3.0
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
package com.macro.mall.portal.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.service.AuthorizationScope;
|
||||
import springfox.documentation.service.SecurityReference;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger API文档相关配置
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2Config {
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.macro.mall.portal.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts());
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("mall前台系统")
|
||||
.description("mall前台模块")
|
||||
.contact("macro")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<ApiKey> securitySchemes() {
|
||||
//设置请求头信息
|
||||
List<ApiKey> result = new ArrayList<>();
|
||||
ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
|
||||
result.add(apiKey);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<SecurityContext> securityContexts() {
|
||||
//设置需要登录认证的路径
|
||||
List<SecurityContext> result = new ArrayList<>();
|
||||
result.add(getContextByPath("/*/.*"));
|
||||
return result;
|
||||
}
|
||||
|
||||
private SecurityContext getContextByPath(String pathRegex) {
|
||||
return SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.forPaths(PathSelectors.regex(pathRegex))
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<SecurityReference> defaultAuth() {
|
||||
List<SecurityReference> result = new ArrayList<>();
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
result.add(new SecurityReference("Authorization", authorizationScopes));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.macro.mall.portal.config;
|
||||
|
||||
import com.macro.mall.common.config.BaseSwaggerConfig;
|
||||
import com.macro.mall.common.domain.SwaggerProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* Swagger2API文档的配置
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig extends BaseSwaggerConfig {
|
||||
|
||||
@Override
|
||||
public SwaggerProperties swaggerProperties() {
|
||||
return SwaggerProperties.builder()
|
||||
.apiBasePackage("com.macro.mall.portal.controller")
|
||||
.title("mall前台系统")
|
||||
.description("mall前台相关接口文档")
|
||||
.contactName("macro")
|
||||
.version("1.0")
|
||||
.enableSecurity(true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.common.api.CommonPage;
|
||||
import com.macro.mall.common.exception.Asserts;
|
||||
import com.macro.mall.common.service.RedisService;
|
||||
import com.macro.mall.mapper.*;
|
||||
import com.macro.mall.model.*;
|
||||
import com.macro.mall.portal.component.CancelOrderSender;
|
||||
@@ -13,7 +14,6 @@ import com.macro.mall.portal.dao.PortalOrderItemDao;
|
||||
import com.macro.mall.portal.dao.SmsCouponHistoryDao;
|
||||
import com.macro.mall.portal.domain.*;
|
||||
import com.macro.mall.portal.service.*;
|
||||
import com.macro.mall.security.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.macro.mall.portal.service.impl;
|
||||
|
||||
import com.macro.mall.common.service.RedisService;
|
||||
import com.macro.mall.mapper.UmsMemberMapper;
|
||||
import com.macro.mall.model.UmsMember;
|
||||
import com.macro.mall.portal.service.UmsMemberCacheService;
|
||||
import com.macro.mall.security.annotation.CacheException;
|
||||
import com.macro.mall.security.config.RedisConfig;
|
||||
import com.macro.mall.security.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -15,32 +15,29 @@ spring:
|
||||
stat-view-servlet: #访问监控网页的登录用户名和密码
|
||||
login-username: druid
|
||||
login-password: druid
|
||||
|
||||
data:
|
||||
mongodb:
|
||||
host: localhost
|
||||
port: 27017
|
||||
database: mall-port
|
||||
|
||||
redis:
|
||||
host: localhost # Redis服务器地址
|
||||
database: 0 # Redis数据库索引(默认为0)
|
||||
port: 6379 # Redis服务器连接端口
|
||||
password: # Redis服务器连接密码(默认为空)
|
||||
timeout: 300ms # 连接超时时间(毫秒)
|
||||
|
||||
rabbitmq:
|
||||
host: localhost
|
||||
port: 5672
|
||||
virtual-host: /mall
|
||||
username: mall
|
||||
password: mall
|
||||
publisher-confirms: true #如果对异步消息需要回调必须设置为true
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
org.springframework.data.mongodb.core: debug
|
||||
com.macro.mall.mapper: debug
|
||||
com.macro.mall.portal.dao: debug
|
||||
root: info
|
||||
com.macro.mall: debug
|
||||
|
||||
logstash:
|
||||
host: localhost
|
||||
|
||||
|
||||
@@ -35,8 +35,14 @@ spring:
|
||||
virtual-host: /mall
|
||||
username: mall
|
||||
password: mall
|
||||
publisher-confirms: true #如果对异步消息需要回调必须设置为true
|
||||
# 日志配置
|
||||
logging:
|
||||
path: /var/logs
|
||||
|
||||
logging:
|
||||
file:
|
||||
path: /var/logs
|
||||
level:
|
||||
root: info
|
||||
com.macro.mall: info
|
||||
|
||||
logstash:
|
||||
host: logstash
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
spring:
|
||||
application:
|
||||
name: mall-portal
|
||||
profiles:
|
||||
active: dev #默认为开发环境
|
||||
|
||||
|
||||
Reference in New Issue
Block a user