diff --git a/mall-admin/pom.xml b/mall-admin/pom.xml
index 35e2cbf..12e2dfb 100644
--- a/mall-admin/pom.xml
+++ b/mall-admin/pom.xml
@@ -57,7 +57,7 @@
spring-boot-maven-plugin
- com.spotify
+ io.fabric8
docker-maven-plugin
diff --git a/mall-admin/src/main/java/com/macro/mall/config/SwaggerConfig.java b/mall-admin/src/main/java/com/macro/mall/config/SwaggerConfig.java
index 5b5d324..c06fa89 100644
--- a/mall-admin/src/main/java/com/macro/mall/config/SwaggerConfig.java
+++ b/mall-admin/src/main/java/com/macro/mall/config/SwaggerConfig.java
@@ -2,6 +2,8 @@ package com.macro.mall.config;
import com.macro.mall.common.config.BaseSwaggerConfig;
import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -24,4 +26,9 @@ public class SwaggerConfig extends BaseSwaggerConfig {
.enableSecurity(true)
.build();
}
+
+ @Bean
+ public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
+ return generateBeanPostProcessor();
+ }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java b/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java
index 71e015b..859bcd7 100644
--- a/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java
+++ b/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java
@@ -12,10 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.text.SimpleDateFormat;
@@ -43,7 +40,7 @@ public class MinioController {
@ApiOperation("文件上传")
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
- public CommonResult upload(@RequestParam("file") MultipartFile file) {
+ public CommonResult upload(@RequestPart("file") MultipartFile file) {
try {
//创建一个MinIO的Java客户端
MinioClient minioClient =MinioClient.builder()
diff --git a/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java b/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
index 62debce..2c668b9 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
@@ -82,4 +82,9 @@ public interface UmsAdminService {
* 获取当前登录后台用户
*/
UmsAdmin getCurrentAdmin();
+
+ /**
+ * 获取缓存服务
+ */
+ UmsAdminCacheService getCacheService();
}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
index b6d2917..633589c 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
@@ -3,6 +3,7 @@ package com.macro.mall.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.BCrypt;
+import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageHelper;
import com.macro.mall.common.api.CommonResult;
@@ -52,8 +53,6 @@ public class UmsAdminServiceImpl implements UmsAdminService {
@Autowired
private AuthService authService;
@Autowired
- private UmsAdminCacheService adminCacheService;
- @Autowired
private HttpServletRequest request;
@Override
@@ -166,14 +165,14 @@ public class UmsAdminServiceImpl implements UmsAdminService {
}
}
int count = adminMapper.updateByPrimaryKeySelective(admin);
- adminCacheService.delAdmin(id);
+ getCacheService().delAdmin(id);
return count;
}
@Override
public int delete(Long id) {
int count = adminMapper.deleteByPrimaryKey(id);
- adminCacheService.delAdmin(id);
+ getCacheService().delAdmin(id);
return count;
}
@@ -227,7 +226,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
}
umsAdmin.setPassword(BCrypt.hashpw(param.getNewPassword()));
adminMapper.updateByPrimaryKey(umsAdmin);
- adminCacheService.delAdmin(umsAdmin.getId());
+ getCacheService().delAdmin(umsAdmin.getId());
return 1;
}
@@ -255,13 +254,18 @@ public class UmsAdminServiceImpl implements UmsAdminService {
Asserts.fail(ResultCode.UNAUTHORIZED);
}
UserDto userDto = JSONUtil.toBean(userStr, UserDto.class);
- UmsAdmin admin = adminCacheService.getAdmin(userDto.getId());
+ UmsAdmin admin = getCacheService().getAdmin(userDto.getId());
if(admin!=null){
return admin;
}else{
admin = adminMapper.selectByPrimaryKey(userDto.getId());
- adminCacheService.setAdmin(admin);
+ getCacheService().setAdmin(admin);
return admin;
}
}
+
+ @Override
+ public UmsAdminCacheService getCacheService() {
+ return SpringUtil.getBean(UmsAdminCacheService.class);
+ }
}
diff --git a/mall-admin/src/main/resources/application.yml b/mall-admin/src/main/resources/application.yml
index 93213fb..1232c09 100644
--- a/mall-admin/src/main/resources/application.yml
+++ b/mall-admin/src/main/resources/application.yml
@@ -1,8 +1,11 @@
server:
port: 8080
spring:
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
datasource:
- url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+ url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: root
druid:
@@ -60,13 +63,16 @@ aliyun:
dir:
prefix: mall/images/ # 上传文件夹路径前缀
minio:
- endpoint: http://192.168.6.132:9090 #MinIO服务所在地址
+ endpoint: http://locahost:9000 #MinIO服务所在地址
bucketName: mall #存储桶名称
accessKey: minioadmin #访问的key
secretKey: minioadmin #访问的秘钥
feign:
okhttp:
enabled: true
-ribbon:
- ConnectTimeout: 3000 #服务请求连接超时时间(毫秒)
- ReadTimeout: 3000 #服务请求处理超时时间(毫秒)
\ No newline at end of file
+ client:
+ config:
+ default:
+ connectTimeout: 5000
+ readTimeout: 5000
+ loggerLevel: basic
\ No newline at end of file
diff --git a/mall-admin/src/test/com/macro/mall/PmsDaoTests.java b/mall-admin/src/test/com/macro/mall/PmsDaoTests.java
index 57db02c..169e6e5 100644
--- a/mall-admin/src/test/com/macro/mall/PmsDaoTests.java
+++ b/mall-admin/src/test/com/macro/mall/PmsDaoTests.java
@@ -6,22 +6,20 @@ import com.macro.mall.dao.PmsMemberPriceDao;
import com.macro.mall.dao.PmsProductDao;
import com.macro.mall.dto.PmsProductResult;
import com.macro.mall.model.PmsMemberPrice;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
-@RunWith(SpringRunner.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
@SpringBootTest
public class PmsDaoTests {
@Autowired
@@ -42,7 +40,7 @@ public class PmsDaoTests {
list.add(memberPrice);
}
int count = memberPriceDao.insertList(list);
- Assert.assertEquals(5,count);
+ assertEquals(5,count);
}
@Test
diff --git a/mall-auth/pom.xml b/mall-auth/pom.xml
index 6e08b23..b57b3bc 100644
--- a/mall-auth/pom.xml
+++ b/mall-auth/pom.xml
@@ -48,6 +48,7 @@
org.springframework.cloud
spring-cloud-starter-oauth2
+ ${spring-cloud-starter-oauth2.version}
com.nimbusds
@@ -70,7 +71,7 @@
spring-boot-maven-plugin
- com.spotify
+ io.fabric8
docker-maven-plugin
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/config/SwaggerConfig.java b/mall-auth/src/main/java/com/macro/mall/auth/config/SwaggerConfig.java
index 4de6626..7581364 100644
--- a/mall-auth/src/main/java/com/macro/mall/auth/config/SwaggerConfig.java
+++ b/mall-auth/src/main/java/com/macro/mall/auth/config/SwaggerConfig.java
@@ -2,6 +2,8 @@ package com.macro.mall.auth.config;
import com.macro.mall.common.config.BaseSwaggerConfig;
import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -24,4 +26,9 @@ public class SwaggerConfig extends BaseSwaggerConfig {
.enableSecurity(true)
.build();
}
+
+ @Bean
+ public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
+ return generateBeanPostProcessor();
+ }
}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/config/WebSecurityConfig.java b/mall-auth/src/main/java/com/macro/mall/auth/config/WebSecurityConfig.java
index 537f831..485b08f 100644
--- a/mall-auth/src/main/java/com/macro/mall/auth/config/WebSecurityConfig.java
+++ b/mall-auth/src/main/java/com/macro/mall/auth/config/WebSecurityConfig.java
@@ -24,6 +24,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll()
.antMatchers("/rsa/publicKey").permitAll()
.antMatchers("/v2/api-docs").permitAll()
+ .antMatchers("/oauth/token").permitAll()
.anyRequest().authenticated();
}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/controller/KeyPairController.java b/mall-auth/src/main/java/com/macro/mall/auth/controller/KeyPairController.java
index c21c1a2..a082add 100644
--- a/mall-auth/src/main/java/com/macro/mall/auth/controller/KeyPairController.java
+++ b/mall-auth/src/main/java/com/macro/mall/auth/controller/KeyPairController.java
@@ -2,8 +2,10 @@ package com.macro.mall.auth.controller;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.RSAKey;
+import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.KeyPair;
@@ -15,12 +17,14 @@ import java.util.Map;
* Created by macro on 2020/6/19.
*/
@RestController
+@Api(tags = "KeyPairController", description = "获取RSA公钥接口")
+@RequestMapping("/rsa")
public class KeyPairController {
@Autowired
private KeyPair keyPair;
- @GetMapping("/rsa/publicKey")
+ @GetMapping("/publicKey")
public Map getKey() {
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
RSAKey key = new RSAKey.Builder(publicKey).build();
diff --git a/mall-auth/src/main/resources/application.yml b/mall-auth/src/main/resources/application.yml
index b66c00d..8739741 100644
--- a/mall-auth/src/main/resources/application.yml
+++ b/mall-auth/src/main/resources/application.yml
@@ -1,5 +1,10 @@
+
server:
port: 8401
+spring:
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
management:
endpoints:
web:
@@ -8,6 +13,9 @@ management:
feign:
okhttp:
enabled: true
-ribbon:
- ConnectTimeout: 3000 #服务请求连接超时时间(毫秒)
- ReadTimeout: 3000 #服务请求处理超时时间(毫秒)
+ client:
+ config:
+ default:
+ connectTimeout: 5000
+ readTimeout: 5000
+ loggerLevel: basic
diff --git a/mall-common/pom.xml b/mall-common/pom.xml
index 902a2eb..8bb70e4 100644
--- a/mall-common/pom.xml
+++ b/mall-common/pom.xml
@@ -46,6 +46,14 @@
org.springframework.boot
spring-boot-starter-validation
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
\ No newline at end of file
diff --git a/mall-common/src/main/java/com/macro/mall/common/config/BaseSwaggerConfig.java b/mall-common/src/main/java/com/macro/mall/common/config/BaseSwaggerConfig.java
index 011af3e..9c432da 100644
--- a/mall-common/src/main/java/com/macro/mall/common/config/BaseSwaggerConfig.java
+++ b/mall-common/src/main/java/com/macro/mall/common/config/BaseSwaggerConfig.java
@@ -1,7 +1,11 @@
package com.macro.mall.common.config;
import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
@@ -9,9 +13,13 @@ import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
+import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
/**
* Swagger基础配置
@@ -43,9 +51,9 @@ public abstract class BaseSwaggerConfig {
.build();
}
- private List securitySchemes() {
+ private List securitySchemes() {
//设置请求头信息
- List result = new ArrayList<>();
+ List result = new ArrayList<>();
ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
result.add(apiKey);
return result;
@@ -74,8 +82,41 @@ public abstract class BaseSwaggerConfig {
return result;
}
+ public BeanPostProcessor generateBeanPostProcessor() {
+ return new BeanPostProcessor() {
+
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
+ customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
+ }
+ return bean;
+ }
+
+ private void customizeSpringfoxHandlerMappings(List mappings) {
+ List copy = mappings.stream()
+ .filter(mapping -> mapping.getPatternParser() == null)
+ .collect(Collectors.toList());
+ mappings.clear();
+ mappings.addAll(copy);
+ }
+
+ @SuppressWarnings("unchecked")
+ private List getHandlerMappings(Object bean) {
+ try {
+ Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
+ field.setAccessible(true);
+ return (List) field.get(bean);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ };
+ }
+
/**
* 自定义Swagger配置
*/
public abstract SwaggerProperties swaggerProperties();
+
}
diff --git a/mall-demo/pom.xml b/mall-demo/pom.xml
index 8d06008..5502910 100644
--- a/mall-demo/pom.xml
+++ b/mall-demo/pom.xml
@@ -49,10 +49,6 @@
org.springframework.boot
spring-boot-maven-plugin
-
- com.spotify
- docker-maven-plugin
-
diff --git a/mall-demo/src/main/java/com/macro/mall/demo/config/SwaggerConfig.java b/mall-demo/src/main/java/com/macro/mall/demo/config/SwaggerConfig.java
index 62d7952..9794969 100644
--- a/mall-demo/src/main/java/com/macro/mall/demo/config/SwaggerConfig.java
+++ b/mall-demo/src/main/java/com/macro/mall/demo/config/SwaggerConfig.java
@@ -2,6 +2,8 @@ package com.macro.mall.demo.config;
import com.macro.mall.common.config.BaseSwaggerConfig;
import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -25,4 +27,9 @@ public class SwaggerConfig extends BaseSwaggerConfig {
.build();
}
+ @Bean
+ public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
+ return generateBeanPostProcessor();
+ }
+
}
diff --git a/mall-demo/src/main/resources/application.yml b/mall-demo/src/main/resources/application.yml
index a239517..6d23634 100644
--- a/mall-demo/src/main/resources/application.yml
+++ b/mall-demo/src/main/resources/application.yml
@@ -1,8 +1,11 @@
server:
port: 8082
spring:
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
datasource:
- url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+ url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: root
mybatis:
diff --git a/mall-demo/src/test/java/com/macro/mall/MallDemoApplicationTests.java b/mall-demo/src/test/java/com/macro/mall/MallDemoApplicationTests.java
index 68052d4..bc4dbd7 100644
--- a/mall-demo/src/test/java/com/macro/mall/MallDemoApplicationTests.java
+++ b/mall-demo/src/test/java/com/macro/mall/MallDemoApplicationTests.java
@@ -2,14 +2,12 @@ package com.macro.mall;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.macro.mall.model.PmsProduct;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
@SpringBootTest
public class MallDemoApplicationTests {
private Logger logger = LoggerFactory.getLogger(MallDemoApplicationTests.class);
diff --git a/mall-gateway/pom.xml b/mall-gateway/pom.xml
index 881d39b..d51bdb5 100644
--- a/mall-gateway/pom.xml
+++ b/mall-gateway/pom.xml
@@ -23,6 +23,10 @@
org.springframework.boot
spring-boot-starter-web
+
+ com.github.xiaoymin
+ knife4j-micro-spring-boot-starter
+
@@ -74,7 +78,7 @@
spring-boot-maven-plugin
- com.spotify
+ io.fabric8
docker-maven-plugin
diff --git a/mall-gateway/src/main/resources/application.yml b/mall-gateway/src/main/resources/application.yml
index bf39f5b..cc55c53 100644
--- a/mall-gateway/src/main/resources/application.yml
+++ b/mall-gateway/src/main/resources/application.yml
@@ -1,6 +1,9 @@
server:
port: 8201
spring:
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
cloud:
gateway:
discovery:
@@ -54,12 +57,12 @@ secure:
- "/doc.html"
- "/swagger-resources/**"
- "/swagger/**"
- - "/**/v2/api-docs"
- - "/**/*.js"
- - "/**/*.css"
- - "/**/*.png"
- - "/**/*.ico"
- - "/webjars/springfox-swagger-ui/**"
+ - "/*/v2/api-docs"
+ - "/*/*.js"
+ - "/*/*.css"
+ - "/*/*.png"
+ - "/*/*.ico"
+ - "/webjars/**"
- "/actuator/**"
- "/mall-auth/oauth/token"
- "/mall-auth/rsa/publicKey"
diff --git a/mall-gateway/src/test/java/com/macro/mall/MallGatewayApplicationTests.java b/mall-gateway/src/test/java/com/macro/mall/MallGatewayApplicationTests.java
index d10b59c..5f34452 100644
--- a/mall-gateway/src/test/java/com/macro/mall/MallGatewayApplicationTests.java
+++ b/mall-gateway/src/test/java/com/macro/mall/MallGatewayApplicationTests.java
@@ -1,11 +1,9 @@
package com.macro.mall;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
@SpringBootTest
public class MallGatewayApplicationTests {
diff --git a/mall-monitor/pom.xml b/mall-monitor/pom.xml
index 615622c..6e97bbc 100644
--- a/mall-monitor/pom.xml
+++ b/mall-monitor/pom.xml
@@ -40,7 +40,7 @@
spring-boot-maven-plugin
- com.spotify
+ io.fabric8
docker-maven-plugin
diff --git a/mall-monitor/src/test/java/com/macro/mall/MallMonitorApplicationTests.java b/mall-monitor/src/test/java/com/macro/mall/MallMonitorApplicationTests.java
index 77e3b62..375d70f 100644
--- a/mall-monitor/src/test/java/com/macro/mall/MallMonitorApplicationTests.java
+++ b/mall-monitor/src/test/java/com/macro/mall/MallMonitorApplicationTests.java
@@ -1,11 +1,9 @@
package com.macro.mall;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
@SpringBootTest
public class MallMonitorApplicationTests {
diff --git a/mall-portal/pom.xml b/mall-portal/pom.xml
index ba58d20..4bafba0 100644
--- a/mall-portal/pom.xml
+++ b/mall-portal/pom.xml
@@ -62,7 +62,7 @@
spring-boot-maven-plugin
- com.spotify
+ io.fabric8
docker-maven-plugin
diff --git a/mall-portal/src/main/java/com/macro/mall/portal/config/SwaggerConfig.java b/mall-portal/src/main/java/com/macro/mall/portal/config/SwaggerConfig.java
index c71b2a8..d14e6bf 100644
--- a/mall-portal/src/main/java/com/macro/mall/portal/config/SwaggerConfig.java
+++ b/mall-portal/src/main/java/com/macro/mall/portal/config/SwaggerConfig.java
@@ -2,6 +2,8 @@ package com.macro.mall.portal.config;
import com.macro.mall.common.config.BaseSwaggerConfig;
import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -24,4 +26,9 @@ public class SwaggerConfig extends BaseSwaggerConfig {
.enableSecurity(true)
.build();
}
+
+ @Bean
+ public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
+ return generateBeanPostProcessor();
+ }
}
diff --git a/mall-portal/src/main/resources/application.yml b/mall-portal/src/main/resources/application.yml
index 03b5955..349b335 100644
--- a/mall-portal/src/main/resources/application.yml
+++ b/mall-portal/src/main/resources/application.yml
@@ -1,8 +1,11 @@
server:
port: 8085
spring:
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
datasource:
- url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+ url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: root
druid:
@@ -63,6 +66,9 @@ rabbitmq:
feign:
okhttp:
enabled: true
-ribbon:
- ConnectTimeout: 3000 #服务请求连接超时时间(毫秒)
- ReadTimeout: 3000 #服务请求处理超时时间(毫秒)
+ client:
+ config:
+ default:
+ connectTimeout: 5000
+ readTimeout: 5000
+ loggerLevel: basic
diff --git a/mall-portal/src/test/java/com/macro/mall/portal/MallPortalApplicationTests.java b/mall-portal/src/test/java/com/macro/mall/portal/MallPortalApplicationTests.java
index 17da1a7..5e22c54 100644
--- a/mall-portal/src/test/java/com/macro/mall/portal/MallPortalApplicationTests.java
+++ b/mall-portal/src/test/java/com/macro/mall/portal/MallPortalApplicationTests.java
@@ -1,11 +1,9 @@
package com.macro.mall.portal;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
@SpringBootTest
public class MallPortalApplicationTests {
diff --git a/mall-portal/src/test/java/com/macro/mall/portal/PortalProductDaoTests.java b/mall-portal/src/test/java/com/macro/mall/portal/PortalProductDaoTests.java
index 228f6e8..92d5ad3 100644
--- a/mall-portal/src/test/java/com/macro/mall/portal/PortalProductDaoTests.java
+++ b/mall-portal/src/test/java/com/macro/mall/portal/PortalProductDaoTests.java
@@ -2,9 +2,7 @@ package com.macro.mall.portal;
import com.macro.mall.portal.dao.PortalProductDao;
import com.macro.mall.portal.domain.PromotionProduct;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -12,11 +10,12 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Created by macro on 2018/8/27.
* 前台商品查询逻辑单元测试
*/
-@RunWith(SpringRunner.class)
@SpringBootTest
public class PortalProductDaoTests {
@Autowired
@@ -29,6 +28,6 @@ public class PortalProductDaoTests {
ids.add(28L);
ids.add(29L);
List promotionProductList = portalProductDao.getPromotionProductList(ids);
- Assert.assertEquals(4,promotionProductList.size());
+ assertEquals(4,promotionProductList.size());
}
}
diff --git a/mall-search/pom.xml b/mall-search/pom.xml
index aa2699b..625275a 100644
--- a/mall-search/pom.xml
+++ b/mall-search/pom.xml
@@ -53,7 +53,7 @@
spring-boot-maven-plugin
- com.spotify
+ io.fabric8
docker-maven-plugin
diff --git a/mall-search/src/main/java/com/macro/mall/search/config/SwaggerConfig.java b/mall-search/src/main/java/com/macro/mall/search/config/SwaggerConfig.java
index d7b1352..23edcd3 100644
--- a/mall-search/src/main/java/com/macro/mall/search/config/SwaggerConfig.java
+++ b/mall-search/src/main/java/com/macro/mall/search/config/SwaggerConfig.java
@@ -2,6 +2,8 @@ package com.macro.mall.search.config;
import com.macro.mall.common.config.BaseSwaggerConfig;
import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -24,4 +26,9 @@ public class SwaggerConfig extends BaseSwaggerConfig {
.enableSecurity(false)
.build();
}
+
+ @Bean
+ public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
+ return generateBeanPostProcessor();
+ }
}
diff --git a/mall-search/src/main/java/com/macro/mall/search/domain/EsProduct.java b/mall-search/src/main/java/com/macro/mall/search/domain/EsProduct.java
index 7239885..8fb0d5b 100644
--- a/mall-search/src/main/java/com/macro/mall/search/domain/EsProduct.java
+++ b/mall-search/src/main/java/com/macro/mall/search/domain/EsProduct.java
@@ -4,6 +4,7 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
+import org.springframework.data.elasticsearch.annotations.Setting;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -13,7 +14,8 @@ import java.util.List;
* 搜索商品的信息
* Created by macro on 2018/6/19.
*/
-@Document(indexName = "pms", type = "product",shards = 1,replicas = 0)
+@Document(indexName = "pms")
+@Setting(shards = 1,replicas = 0)
public class EsProduct implements Serializable {
private static final long serialVersionUID = -1L;
@Id
diff --git a/mall-search/src/main/java/com/macro/mall/search/service/impl/EsProductServiceImpl.java b/mall-search/src/main/java/com/macro/mall/search/service/impl/EsProductServiceImpl.java
index 004fb94..a0bb232 100644
--- a/mall-search/src/main/java/com/macro/mall/search/service/impl/EsProductServiceImpl.java
+++ b/mall-search/src/main/java/com/macro/mall/search/service/impl/EsProductServiceImpl.java
@@ -13,6 +13,7 @@ import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
+import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.filter.ParsedFilter;
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
import org.elasticsearch.search.aggregations.bucket.terms.ParsedLongTerms;
@@ -247,7 +248,7 @@ public class EsProductServiceImpl implements EsProductService {
*/
private EsProductRelatedInfo convertProductRelatedInfo(SearchHits response) {
EsProductRelatedInfo productRelatedInfo = new EsProductRelatedInfo();
- Map aggregationMap = response.getAggregations().getAsMap();
+ Map aggregationMap = ((Aggregations)response.getAggregations().aggregations()).asMap();
//设置品牌
Aggregation brandNames = aggregationMap.get("brandNames");
List brandNameList = new ArrayList<>();
diff --git a/mall-search/src/main/resources/application.yml b/mall-search/src/main/resources/application.yml
index 91f581c..f8f9304 100644
--- a/mall-search/src/main/resources/application.yml
+++ b/mall-search/src/main/resources/application.yml
@@ -1,8 +1,11 @@
server:
port: 8081
spring:
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
datasource:
- url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+ url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: root
druid:
@@ -19,8 +22,7 @@ spring:
repositories:
enabled: true
elasticsearch:
- rest:
- uris: 127.0.0.1:9200
+ uris: localhost:9200
mybatis:
mapper-locations:
- classpath:dao/*.xml
diff --git a/mall-search/src/test/java/com/macro/mall/search/MallSearchApplicationTests.java b/mall-search/src/test/java/com/macro/mall/search/MallSearchApplicationTests.java
index 7de5d73..5f070a9 100644
--- a/mall-search/src/test/java/com/macro/mall/search/MallSearchApplicationTests.java
+++ b/mall-search/src/test/java/com/macro/mall/search/MallSearchApplicationTests.java
@@ -3,8 +3,7 @@ package com.macro.mall.search;
import com.macro.mall.search.dao.EsProductDao;
import com.macro.mall.search.domain.EsProduct;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
@@ -14,7 +13,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import java.util.Map;
-@RunWith(SpringRunner.class)
@SpringBootTest
public class MallSearchApplicationTests {
@Autowired
diff --git a/pom.xml b/pom.xml
index a2044e8..b4da83d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.3.0.RELEASE
+ 2.7.0
@@ -32,26 +32,28 @@
UTF-8
UTF-8
true
- http://192.168.3.101:2375
- 1.2.2
+ http://192.168.3.105:2375
+ 0.40.0
1.8
- Hoxton.SR5
- 2.2.0.RELEASE
- 1.3.0
- 5.2.0
- 1.1.23
- 5.4.0
- 1.4.0
- 3.5.5
- 8.0.20
- 2.3.0.RELEASE
- 0.9.0
+ 2.7.0
+ 2021.0.3
+ 2021.0.1.0
+ 2.2.5.RELEASE
+ 1.4.2
+ 5.3.0
+ 1.2.9
+ 5.8.0
+ 1.4.1
+ 3.5.9
+ 8.0.29
+ 2.7.0
+ 0.9.1
2.5.0
5.3
- 2.2.3
- 7.1.0
- 2.0.4
- 8.16
+ 2.7.0
+ 8.4.1
+ 3.0.3
+ 9.23
1.0-SNAPSHOT
1.0-SNAPSHOT
@@ -219,32 +221,50 @@
org.springframework.boot
spring-boot-maven-plugin
+ ${spring-boot.version}
- com.spotify
+ io.fabric8
docker-maven-plugin
${docker.maven.plugin.version}
-
-
-
-
-
-
-
-
-
+
+
+
+ build-image
+ package
+
+ build
+
+
+
- mall/${project.artifactId}:${project.version}
+
${docker.host}
- java:8
- ["java", "-jar", "-Dspring.profiles.active=prod","/${project.build.finalName}.jar"]
-
-
- /
- ${project.build.directory}
- ${project.build.finalName}.jar
-
-
+
+
+
+ mall/${project.name}:${project.version}
+
+
+
+ java:8
+
+ ${project.build.finalName}.jar
+
+
+
+
+ /
+
+ artifact
+
+
+ ["java", "-jar","-Dspring.profiles.active=prod","/${project.build.finalName}.jar"]
+
+ macrozheng
+
+
+