From 7f5038e5628991b5da14052dd3f6a13bec9df3cc Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Wed, 1 May 2019 12:08:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=20Dubbo=20=E5=88=B0=202.7.1?= =?UTF-8?q?=20=E3=80=82=E7=9B=AE=E5=89=8D=20Dubbo=20=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=AD=98=E5=9C=A8=20Bug=20=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E4=BB=A5=E9=9C=80=E8=A6=81=E4=BD=BF=E7=94=A8=20@Autowire=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admins/AdminController.java | 10 ++++-- .../controller/admins/DataDictController.java | 4 ++- .../controller/admins/PassportController.java | 4 ++- .../controller/admins/ResourceController.java | 4 ++- .../controller/admins/RoleController.java | 7 ++-- .../AdminAccessLogInterceptor.java | 4 ++- .../interceptor/AdminSecurityInterceptor.java | 4 ++- product/product-application/pom.xml | 34 ++++--------------- .../admins/AdminsProductAttrController.java | 2 ++ .../AdminsProductCategoryController.java | 2 ++ .../admins/AdminsProductSpuController.java | 1 + .../users/UsersProductCategoryController.java | 2 ++ .../users/UsersProductSpuController.java | 2 ++ product/product-service-impl/pom.xml | 12 +++++++ 14 files changed, 54 insertions(+), 38 deletions(-) diff --git a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/AdminController.java b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/AdminController.java index 95a68fbc7..6c3f6998e 100644 --- a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/AdminController.java +++ b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/AdminController.java @@ -23,6 +23,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.dubbo.config.annotation.Reference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.*; @@ -33,11 +34,14 @@ import java.util.stream.Collectors; @Api("管理员模块") public class AdminController { - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private ResourceService resourceService; - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private AdminService adminService; - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private RoleService roleService; // =========== 当前管理员相关的资源 API =========== diff --git a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/DataDictController.java b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/DataDictController.java index 2bf7a66e1..d69c96fe2 100644 --- a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/DataDictController.java +++ b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/DataDictController.java @@ -16,6 +16,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -26,7 +27,8 @@ import java.util.List; @Api("数据字典模块") public class DataDictController { - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private DataDictService dataDictService; @GetMapping("/list") diff --git a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/PassportController.java b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/PassportController.java index 8903b9ac5..8f807c2d9 100644 --- a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/PassportController.java +++ b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/PassportController.java @@ -10,6 +10,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.dubbo.config.annotation.Reference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -20,7 +21,8 @@ import org.springframework.web.bind.annotation.RestController; @Api("Admin Passport 模块") public class PassportController { - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private OAuth2Service oauth2Service; @PostMapping("/login") diff --git a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/ResourceController.java b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/ResourceController.java index 3fb45e1d9..2362c62ee 100644 --- a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/ResourceController.java +++ b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/ResourceController.java @@ -15,6 +15,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -28,7 +29,8 @@ import java.util.stream.Collectors; @Api("资源模块") public class ResourceController { - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private ResourceService resourceService; @SuppressWarnings("Duplicates") diff --git a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/RoleController.java b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/RoleController.java index 3560fc518..4d8aa3f90 100644 --- a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/RoleController.java +++ b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/RoleController.java @@ -20,6 +20,7 @@ import org.apache.dubbo.config.annotation.Reference; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.*; @@ -29,9 +30,11 @@ import java.util.stream.Collectors; @RequestMapping("admins/role") public class RoleController { - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private RoleService roleService; - @Reference(validation = "true", lazy = true) + @Reference(validation = "true") + @Autowired // TODO Dubbo 2.7.2 移除 bug private ResourceService resourceService; @GetMapping("/page") diff --git a/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminAccessLogInterceptor.java b/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminAccessLogInterceptor.java index d101dde3a..57476d6ad 100644 --- a/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminAccessLogInterceptor.java +++ b/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminAccessLogInterceptor.java @@ -8,6 +8,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.dubbo.config.annotation.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; @@ -32,7 +33,8 @@ public class AdminAccessLogInterceptor extends HandlerInterceptorAdapter { */ private static final ThreadLocal ADMIN_ID = new ThreadLocal<>(); - @Reference(lazy = true) // TODO 芋艿,初始化时,会存在 spring boot 启动时,服务无法引用的情况,先暂时这么解决。 + @Reference(lazy = true) + @Autowired(required = false) // TODO 芋艿,初始化时,会存在 spring boot 启动时,服务无法引用的情况,先暂时这么解决。 private AdminAccessLogService adminAccessLogService; @Override diff --git a/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java b/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java index 1845793e1..df5227d2d 100644 --- a/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java +++ b/admin/admin-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java @@ -9,6 +9,7 @@ import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContext; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import org.apache.dubbo.config.annotation.Reference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; @@ -22,7 +23,8 @@ import java.util.Set; @Component public class AdminSecurityInterceptor extends HandlerInterceptorAdapter { - @Reference(lazy = true) // TODO 芋艿,初始化时,会存在 spring boot 启动时,服务无法引用的情况,先暂时这么解决。 + @Reference(validation = "true") + @Autowired(required = false) // TODO 芋艿,初始化时,会存在 spring boot 启动时,服务无法引用的情况,先暂时这么解决。 private OAuth2Service oauth2Service; @Override diff --git a/product/product-application/pom.xml b/product/product-application/pom.xml index b66f0b947..fc84fb7b1 100644 --- a/product/product-application/pom.xml +++ b/product/product-application/pom.xml @@ -27,6 +27,11 @@ product-service-impl 1.0-SNAPSHOT + + cn.iocoder.mall + user-sdk + 1.0-SNAPSHOT + @@ -44,34 +49,12 @@ spring-boot-starter-web - - mysql - mysql-connector-java - - - org.springframework.boot - spring-boot-starter-jdbc - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - - org.springframework.boot spring-boot-starter-test test - - org.apache.dubbo - dubbo-spring-boot-starter - - - org.apache.curator - curator-framework - - io.springfox springfox-swagger2 @@ -80,12 +63,7 @@ io.springfox springfox-swagger-ui - - cn.iocoder.mall - user-sdk - 1.0-SNAPSHOT - compile - + diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java index 9c11bc9ea..a6e57dbe6 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java @@ -18,6 +18,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -28,6 +29,7 @@ import java.util.List; public class AdminsProductAttrController { @Reference(validation = "true") + @Autowired private ProductAttrService productAttrService; @GetMapping("/attr/page") diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java index 78f921ff7..0e5d83990 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java @@ -15,6 +15,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -29,6 +30,7 @@ import java.util.stream.Collectors; public class AdminsProductCategoryController { @Reference(validation = "true") + @Autowired private ProductCategoryService productCategoryService; @GetMapping("/tree") diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java index a5b13b23c..50fcb7f5a 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java @@ -31,6 +31,7 @@ import java.util.List; public class AdminsProductSpuController { @Reference(validation = "true") + @Autowired private ProductSpuService productSpuService; @Autowired diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java index 9b82cdad2..3c4ef1287 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java @@ -10,6 +10,7 @@ import org.apache.dubbo.config.annotation.Reference; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; +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.RequestParam; @@ -23,6 +24,7 @@ import java.util.List; public class UsersProductCategoryController { @Reference(validation = "true") + @Autowired private ProductCategoryService productCategoryService; @GetMapping("/list") diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java index 9760dff38..190a23d1a 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java @@ -13,6 +13,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +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.RequestParam; @@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController; public class UsersProductSpuController { @Reference(validation = "true") + @Autowired private ProductSpuService productSpuService; @GetMapping("/info") diff --git a/product/product-service-impl/pom.xml b/product/product-service-impl/pom.xml index 689429bf9..5ecd08a71 100644 --- a/product/product-service-impl/pom.xml +++ b/product/product-service-impl/pom.xml @@ -36,6 +36,18 @@ org.apache.dubbo dubbo + + org.apache.curator + curator-framework + + + org.apache.curator + curator-recipes + + + org.apache.dubbo + dubbo-spring-boot-starter + com.google.guava