diff --git a/book-coupon/pom.xml b/book-coupon/pom.xml
index 4eaa7ad..93bf053 100644
--- a/book-coupon/pom.xml
+++ b/book-coupon/pom.xml
@@ -50,6 +50,7 @@
spring-boot-starter-test
test
+
diff --git a/book-coupon/src/main/java/com/bookstore/bookmall/coupon/BookCouponApplication.java b/book-coupon/src/main/java/com/bookstore/bookmall/coupon/BookCouponApplication.java
index 87e1efe..d44fa2c 100644
--- a/book-coupon/src/main/java/com/bookstore/bookmall/coupon/BookCouponApplication.java
+++ b/book-coupon/src/main/java/com/bookstore/bookmall/coupon/BookCouponApplication.java
@@ -2,7 +2,36 @@ package com.bookstore.bookmall.coupon;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+/*
+* nacos配置中心
+* 1、引入依赖
+*
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+ 3.1.2
+
+ * 2、创建boostrap.properties
+ * # Nacos 配置中心,地址
+ spring.cloud.nacos.config.server-addr=127.0.0.1:8848
+ #查询组
+ spring.config.import=nacos:book-coupon.properties?group=DEFAULT_GROUP
+*3、在配置中心中添加上面 #设置的名字# 的配置文件,如book-coupon.properties
+* 5、动态刷新配置
+* @RefreshScope
+*
+* 微服务创建自己的命名空间,使用配置分组区分环境
+*
+* */
+
+@RefreshScope
+@EnableDiscoveryClient
@SpringBootApplication
public class BookCouponApplication {
diff --git a/book-coupon/src/main/java/com/bookstore/bookmall/coupon/controller/CouponController.java b/book-coupon/src/main/java/com/bookstore/bookmall/coupon/controller/CouponController.java
index 321e3a8..957165b 100644
--- a/book-coupon/src/main/java/com/bookstore/bookmall/coupon/controller/CouponController.java
+++ b/book-coupon/src/main/java/com/bookstore/bookmall/coupon/controller/CouponController.java
@@ -4,12 +4,10 @@ import java.util.Arrays;
import java.util.Map;
+import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
import com.bookstore.bookmall.coupon.entity.CouponEntity;
import com.bookstore.bookmall.coupon.service.CouponService;
@@ -31,6 +29,25 @@ public class CouponController {
@Autowired
private CouponService couponService;
+ @Value("${coupon.user.name}")
+ String name;
+ @Value("${coupon.user.age}")
+ Integer age;
+
+ @RequestMapping("/config")
+ public R test() {
+ return R.ok().put("name", name).put("age", age);
+ }
+
+
+
+ @RequestMapping("/member/list")
+ public R membercoupons() {
+ CouponEntity couponEntity = new CouponEntity();
+ couponEntity.setCouponName("满100减10");
+ return R.ok().put("coupons", Arrays.asList(couponEntity));
+ }
+
/**
* 列表
*/
diff --git a/book-coupon/src/main/resources/application.properties b/book-coupon/src/main/resources/application.properties
index 2975704..6820a96 100644
--- a/book-coupon/src/main/resources/application.properties
+++ b/book-coupon/src/main/resources/application.properties
@@ -1 +1,4 @@
spring.application.name=book-coupon
+
+coupon.user.name = zhangsna
+coupon.user.age = 18
diff --git a/book-coupon/src/main/resources/application.yml b/book-coupon/src/main/resources/application.yml
index 8b86e31..5927816 100644
--- a/book-coupon/src/main/resources/application.yml
+++ b/book-coupon/src/main/resources/application.yml
@@ -4,6 +4,14 @@ spring:
password: 7536981
url: jdbc:mysql://192.168.88.131:3306/mall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ application:
+ name: mall-coupon
+
+
mybatis-plus:
config-locations: classpath*:/mapper/**/*.xml #classpath*中的*指的是不止引用自己路径的mapper,依赖的jar包也扫描
global-config:
diff --git a/book-coupon/src/main/resources/bootstrap.properties b/book-coupon/src/main/resources/bootstrap.properties
new file mode 100644
index 0000000..5a6d8ae
--- /dev/null
+++ b/book-coupon/src/main/resources/bootstrap.properties
@@ -0,0 +1,23 @@
+
+# Nacos 配置中心,地址
+spring.cloud.nacos.config.server-addr=127.0.0.1:8848
+#查询组
+#spring.config.import=nacos:book-coupon.properties?group=DEFAULT_GROUP
+#设置命名空间
+spring.cloud.nacos.config.namespace=23c53425-ed13-49a2-8cb1-4082e9531b1a
+
+spring.cloud.nacos.config.extension-configs[0].data-id=datasource.yml
+spring.cloud.nacos.config.extension-configs[0].group=dev
+spring.cloud.nacos.config.extension-configs[0].refresh=true
+
+spring.cloud.nacos.config.extension-configs[1].data-id=mybatis.yml
+spring.cloud.nacos.config.extension-configs[1].group=dev
+spring.cloud.nacos.config.extension-configs[1].refresh=true
+
+spring.cloud.nacos.config.extension-configs[2].data-id=other.yml
+spring.cloud.nacos.config.extension-configs[2].group=dev
+spring.cloud.nacos.config.extension-configs[2].refresh=true
+
+
+# 应用名称
+spring.application.name=book-coupon
\ No newline at end of file
diff --git a/book-member/pom.xml b/book-member/pom.xml
index 7e784ed..0265d48 100644
--- a/book-member/pom.xml
+++ b/book-member/pom.xml
@@ -45,6 +45,11 @@
org.springframework.cloud
spring-cloud-starter-openfeign
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
org.springframework.boot
diff --git a/book-member/src/main/java/com/bookstore/bookmall/member/BookMemberApplication.java b/book-member/src/main/java/com/bookstore/bookmall/member/BookMemberApplication.java
index 630e604..73d84fc 100644
--- a/book-member/src/main/java/com/bookstore/bookmall/member/BookMemberApplication.java
+++ b/book-member/src/main/java/com/bookstore/bookmall/member/BookMemberApplication.java
@@ -2,7 +2,11 @@ package com.bookstore.bookmall.member;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+@EnableFeignClients(basePackages = "com.bookstore.bookmall.member.feign")
+@EnableDiscoveryClient
@SpringBootApplication
public class BookMemberApplication {
diff --git a/book-member/src/main/java/com/bookstore/bookmall/member/controller/MemberController.java b/book-member/src/main/java/com/bookstore/bookmall/member/controller/MemberController.java
index d168c12..db23659 100644
--- a/book-member/src/main/java/com/bookstore/bookmall/member/controller/MemberController.java
+++ b/book-member/src/main/java/com/bookstore/bookmall/member/controller/MemberController.java
@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.Map;
+import com.bookstore.bookmall.member.feign.CouponFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
@@ -31,6 +32,18 @@ public class MemberController {
@Autowired
private MemberService memberService;
+ @Autowired
+ CouponFeignService couponFeignService;
+
+ @RequestMapping("/coupon")
+ public R test() {
+ MemberEntity memberEntity = new MemberEntity();
+ memberEntity.setNickname("zhangsan");
+
+ R membercoupons = couponFeignService.membercoupons();
+ return R.ok().put("member", memberEntity).put("coupons", membercoupons.get("coupons"));
+ }
+
/**
* 列表
*/
diff --git a/book-member/src/main/java/com/bookstore/bookmall/member/feign/CouponFeignService.java b/book-member/src/main/java/com/bookstore/bookmall/member/feign/CouponFeignService.java
new file mode 100644
index 0000000..bbf035e
--- /dev/null
+++ b/book-member/src/main/java/com/bookstore/bookmall/member/feign/CouponFeignService.java
@@ -0,0 +1,12 @@
+package com.bookstore.bookmall.member.feign;
+
+import com.bookstore.common.utils.R;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@FeignClient(name = "book-coupon")
+public interface CouponFeignService {
+
+ @RequestMapping("/coupon/coupon/member/list")
+ public R membercoupons();
+}
diff --git a/book-member/src/main/resources/application.yml b/book-member/src/main/resources/application.yml
index cddb6f5..c8a2bd7 100644
--- a/book-member/src/main/resources/application.yml
+++ b/book-member/src/main/resources/application.yml
@@ -4,6 +4,14 @@ spring:
password: 7536981
url: jdbc:mysql://192.168.88.131:3306/mall_ums?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ application:
+ name: mall-member
+
+
mybatis-plus:
config-locations: classpath*:/mapper/**/*.xml #classpath*中的*指的是不止引用自己路径的mapper,依赖的jar包也扫描
global-config:
diff --git a/book-order/src/main/java/com/bookstore/bookmall/order/BookOrderApplication.java b/book-order/src/main/java/com/bookstore/bookmall/order/BookOrderApplication.java
index e90fbd3..3832357 100644
--- a/book-order/src/main/java/com/bookstore/bookmall/order/BookOrderApplication.java
+++ b/book-order/src/main/java/com/bookstore/bookmall/order/BookOrderApplication.java
@@ -2,7 +2,9 @@ package com.bookstore.bookmall.order;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+@EnableDiscoveryClient
@SpringBootApplication
public class BookOrderApplication {
diff --git a/book-order/src/main/resources/application.yml b/book-order/src/main/resources/application.yml
index 4179a7f..c665cd9 100644
--- a/book-order/src/main/resources/application.yml
+++ b/book-order/src/main/resources/application.yml
@@ -4,6 +4,13 @@ spring:
password: 7536981
url: jdbc:mysql://192.168.88.131:3306/mall_oms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ application:
+ name: mall-order
+
mybatis-plus:
config-locations: classpath*:/mapper/**/*.xml #classpath*中的*指的是不止引用自己路径的mapper,依赖的jar包也扫描
global-config:
diff --git a/book-product/src/main/java/com/bookstore/bookmall/product/controller/CategoryController.java b/book-product/src/main/java/com/bookstore/bookmall/product/controller/CategoryController.java
index 08ae608..60c2790 100644
--- a/book-product/src/main/java/com/bookstore/bookmall/product/controller/CategoryController.java
+++ b/book-product/src/main/java/com/bookstore/bookmall/product/controller/CategoryController.java
@@ -1,6 +1,7 @@
package com.bookstore.bookmall.product.controller;
import java.util.Arrays;
+import java.util.List;
import java.util.Map;
@@ -32,14 +33,14 @@ public class CategoryController {
private CategoryService categoryService;
/**
- * 列表
+ * 查出所有分类和子分类,以树形结果组装起来
*/
- @RequestMapping("/list")
+ @RequestMapping("/list/tree")
//@RequiresPermissions("product:category:list")
- public R list(@RequestParam Map params){
- PageUtils page = categoryService.queryPage(params);
+ public R list(){
+ List entities = categoryService.listWithTree();
- return R.ok().put("page", page);
+ return R.ok().put("data", entities);
}
diff --git a/book-product/src/main/java/com/bookstore/bookmall/product/entity/CategoryEntity.java b/book-product/src/main/java/com/bookstore/bookmall/product/entity/CategoryEntity.java
index 1e8c506..f5a77a1 100644
--- a/book-product/src/main/java/com/bookstore/bookmall/product/entity/CategoryEntity.java
+++ b/book-product/src/main/java/com/bookstore/bookmall/product/entity/CategoryEntity.java
@@ -1,10 +1,13 @@
package com.bookstore.bookmall.product.entity;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
+import java.util.List;
+
import lombok.Data;
/**
@@ -57,4 +60,6 @@ public class CategoryEntity implements Serializable {
*/
private Integer productCount;
+ @TableField(exist = false)
+ private List children;
}
diff --git a/book-product/src/main/java/com/bookstore/bookmall/product/mallProductApplication.java b/book-product/src/main/java/com/bookstore/bookmall/product/mallProductApplication.java
index 9a6d1c2..d2680c0 100644
--- a/book-product/src/main/java/com/bookstore/bookmall/product/mallProductApplication.java
+++ b/book-product/src/main/java/com/bookstore/bookmall/product/mallProductApplication.java
@@ -4,6 +4,7 @@ package com.bookstore.bookmall.product;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/*
@@ -21,6 +22,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* */
@MapperScan("com.bookstore.bookmall.product.dao")
+@EnableDiscoveryClient
@SpringBootApplication
public class mallProductApplication {
public static void main(String[] args) {
diff --git a/book-product/src/main/java/com/bookstore/bookmall/product/service/CategoryService.java b/book-product/src/main/java/com/bookstore/bookmall/product/service/CategoryService.java
index 26ccd65..8c93cfb 100644
--- a/book-product/src/main/java/com/bookstore/bookmall/product/service/CategoryService.java
+++ b/book-product/src/main/java/com/bookstore/bookmall/product/service/CategoryService.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bookstore.common.utils.PageUtils;
import com.bookstore.bookmall.product.entity.CategoryEntity;
+import java.util.List;
import java.util.Map;
/**
@@ -16,5 +17,7 @@ import java.util.Map;
public interface CategoryService extends IService {
PageUtils queryPage(Map params);
+
+ List listWithTree();
}
diff --git a/book-product/src/main/java/com/bookstore/bookmall/product/service/impl/CategoryServiceImpl.java b/book-product/src/main/java/com/bookstore/bookmall/product/service/impl/CategoryServiceImpl.java
index 5b555e8..2a75c3e 100644
--- a/book-product/src/main/java/com/bookstore/bookmall/product/service/impl/CategoryServiceImpl.java
+++ b/book-product/src/main/java/com/bookstore/bookmall/product/service/impl/CategoryServiceImpl.java
@@ -1,7 +1,13 @@
package com.bookstore.bookmall.product.service.impl;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+
+import java.util.List;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -16,6 +22,10 @@ import com.bookstore.bookmall.product.service.CategoryService;
@Service("categoryService")
public class CategoryServiceImpl extends ServiceImpl implements CategoryService {
+// @Autowired
+// CategoryDao categoryDao;
+
+
@Override
public PageUtils queryPage(Map params) {
IPage page = this.page(
@@ -26,4 +36,37 @@ public class CategoryServiceImpl extends ServiceImpl listWithTree() {
+ //1、查出所有分类
+ List entities = baseMapper.selectList(null);
+ //2、组装成父子结构
+ List level1 = entities.stream().filter(categoryEntity -> categoryEntity.getParentCid() == 0)
+ .map((menu)->{
+ menu.setChildren(getChildren(menu, entities));
+ return menu;
+ }).sorted((menu1, menu2)-> {
+ return (menu1.getSort() == null ? 0 : menu1.getSort()) - (menu2.getSort() == null ? 0 : menu2.getSort());
+ })
+ .collect(Collectors.toList());
+
+ return level1;
+ }
+
+ private List getChildren(CategoryEntity root, List all) {
+ //过滤器过滤出子菜单
+ List Children = all.stream().filter((categoryEntity -> {
+ return root.getCatId() == categoryEntity.getParentCid();
+ //映射方法填入菜单的子菜单
+ })).map(categoryEntity -> {
+ categoryEntity.setChildren(getChildren(categoryEntity, all));
+ return categoryEntity;
+ //排序
+ }).sorted((menu1, menu2)->{
+ return (menu1.getSort() == null ? 0 : menu1.getSort()) - (menu2.getSort() == null ? 0 : menu2.getSort());
+ }).collect(Collectors.toList());
+
+ return Children;
+ }
+
}
\ No newline at end of file
diff --git a/book-product/src/main/resources/application.yml b/book-product/src/main/resources/application.yml
index b7128d3..29d1777 100644
--- a/book-product/src/main/resources/application.yml
+++ b/book-product/src/main/resources/application.yml
@@ -4,6 +4,13 @@ spring:
password: 7536981
url: jdbc:mysql://192.168.88.131:3306/mall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ application:
+ name: mall-product
+
mybatis-plus:
config-locations: classpath*:/mapper/**/*.xml #classpath*中的*指的是不止引用自己路径的mapper,依赖的jar包也扫描
global-config:
diff --git a/book-ware/src/main/resources/application.yml b/book-ware/src/main/resources/application.yml
index 0c8ca0a..1df8d23 100644
--- a/book-ware/src/main/resources/application.yml
+++ b/book-ware/src/main/resources/application.yml
@@ -4,6 +4,12 @@ spring:
password: 7536981
url: jdbc:mysql://192.168.88.131:3306/mall_wms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1
+ application:
+ name: mall-ware
mybatis-plus:
config-locations: classpath*:/mapper/**/*.xml #classpath*中的*指的是不止引用自己路径的mapper,依赖的jar包也扫描
global-config:
diff --git a/mall-common/mall-common.iml b/mall-common/mall-common.iml
index 1729aec..fc4d4bb 100644
--- a/mall-common/mall-common.iml
+++ b/mall-common/mall-common.iml
@@ -40,9 +40,7 @@
-
-
@@ -52,5 +50,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mall-common/pom.xml b/mall-common/pom.xml
index d0366e5..fd13ada 100644
--- a/mall-common/pom.xml
+++ b/mall-common/pom.xml
@@ -65,8 +65,36 @@
8.0.17
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+ 3.1.2
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ 2021.0.4.0
+ pom
+ import
+
+
+
+
8
diff --git a/mall-gateway/.gitattributes b/mall-gateway/.gitattributes
new file mode 100644
index 0000000..3b41682
--- /dev/null
+++ b/mall-gateway/.gitattributes
@@ -0,0 +1,2 @@
+/mvnw text eol=lf
+*.cmd text eol=crlf
diff --git a/mall-gateway/pom.xml b/mall-gateway/pom.xml
new file mode 100644
index 0000000..3782f0e
--- /dev/null
+++ b/mall-gateway/pom.xml
@@ -0,0 +1,71 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.7.1
+
+
+ com.bookstore.bookmall
+ mall-gateway
+ 0.0.1-SNAPSHOT
+ mall-gateway
+ Demo project for Spring Boot
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+ 2021.0.4.0
+
+
+
+ com.bookstore.bookmall
+ mall-common
+ 0.0.1-SNAPSHOT
+
+
+ org.springframework.cloud
+ spring-cloud-starter-gateway
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/mall-gateway/src/main/java/com/bookstore/bookmall/gateway/MallGatewayApplication.java b/mall-gateway/src/main/java/com/bookstore/bookmall/gateway/MallGatewayApplication.java
new file mode 100644
index 0000000..6124cef
--- /dev/null
+++ b/mall-gateway/src/main/java/com/bookstore/bookmall/gateway/MallGatewayApplication.java
@@ -0,0 +1,17 @@
+package com.bookstore.bookmall.gateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+//开启服务发现
+@EnableDiscoveryClient
+@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
+public class MallGatewayApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(MallGatewayApplication.class, args);
+ }
+
+}
diff --git a/mall-gateway/src/main/resources/application.properties b/mall-gateway/src/main/resources/application.properties
new file mode 100644
index 0000000..3984214
--- /dev/null
+++ b/mall-gateway/src/main/resources/application.properties
@@ -0,0 +1 @@
+spring.application.name=mall-gateway
diff --git a/mall-gateway/src/main/resources/application.yml b/mall-gateway/src/main/resources/application.yml
new file mode 100644
index 0000000..13eb15c
--- /dev/null
+++ b/mall-gateway/src/main/resources/application.yml
@@ -0,0 +1,13 @@
+spring:
+ cloud:
+ gateway:
+ routes:
+ - id: test_route
+ uri: https://baidu.com
+ predicates:
+ - Query=url, baidu
+
+ - id: qq_route
+ uri: https://qq.com
+ predicates:
+ - Query=url, qq
\ No newline at end of file
diff --git a/mall-gateway/src/main/resources/bootstrap.properties b/mall-gateway/src/main/resources/bootstrap.properties
new file mode 100644
index 0000000..26cb319
--- /dev/null
+++ b/mall-gateway/src/main/resources/bootstrap.properties
@@ -0,0 +1,3 @@
+spring.cloud.nacos.config.server-addr=127.0.0.1:8848
+spring.cloud.nacos.config.namespace=ae6219bf-ba8f-4608-b356-0a96a9c1b78b
+server.port=88
\ No newline at end of file
diff --git a/mall-gateway/src/test/java/com/bookstore/bookmall/gateway/MallGatewayApplicationTests.java b/mall-gateway/src/test/java/com/bookstore/bookmall/gateway/MallGatewayApplicationTests.java
new file mode 100644
index 0000000..f987060
--- /dev/null
+++ b/mall-gateway/src/test/java/com/bookstore/bookmall/gateway/MallGatewayApplicationTests.java
@@ -0,0 +1,13 @@
+package com.bookstore.bookmall.gateway;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class MallGatewayApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index e0630ad..501d4a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,7 @@
renren-fast
renren-generator
mall-common
+ mall-gateway
diff --git a/renren-fast/docker-compose.yml b/renren-fast/docker-compose.yml
index 432ba38..a99a0e6 100644
--- a/renren-fast/docker-compose.yml
+++ b/renren-fast/docker-compose.yml
@@ -4,5 +4,9 @@ services:
image: renren/fast
ports:
- "8080:8080"
+ - "8848:8848"
+ - "9848:9848"
+ - "9849:9849"
+
environment:
- spring.profiles.active=dev
\ No newline at end of file
diff --git a/renren-fast/pom.xml b/renren-fast/pom.xml
index 13c6cdd..55e517a 100644
--- a/renren-fast/pom.xml
+++ b/renren-fast/pom.xml
@@ -236,8 +236,45 @@
lombok
${lombok.version}
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ com.google.guava
+ guava
+ 31.1-jre
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ 2021.0.4.0
+ pom
+ import
+
+
+
+
+
+
${project.artifactId}
diff --git a/renren-fast/src/main/java/io/renren/RenrenApplication.java b/renren-fast/src/main/java/io/renren/RenrenApplication.java
index 915d6cb..28d6903 100644
--- a/renren-fast/src/main/java/io/renren/RenrenApplication.java
+++ b/renren-fast/src/main/java/io/renren/RenrenApplication.java
@@ -10,8 +10,10 @@ package io.renren;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+@EnableDiscoveryClient
@SpringBootApplication
public class RenrenApplication {
diff --git a/renren-fast/src/main/resources/application.yml b/renren-fast/src/main/resources/application.yml
index 5798856..035b03c 100644
--- a/renren-fast/src/main/resources/application.yml
+++ b/renren-fast/src/main/resources/application.yml
@@ -28,6 +28,12 @@ spring:
throw-exception-if-no-handler-found: true
pathmatch:
matching-strategy: ANT_PATH_MATCHER
+ application:
+ name: renren-fast
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
# resources:
# add-mappings: false
@@ -64,4 +70,5 @@ renren:
secret: f4e2e52034348f86b67cde581c0f9eb5[www.renren.io]
# token有效时长,7天,单位秒
expire: 604800
- header: token
\ No newline at end of file
+ header: token
+