From bf24c3bb836daaa7fed9b730a88dbb5efbf062b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=85=83=E7=9A=93?= Date: Tue, 6 Aug 2024 17:49:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=A4=BE=E5=8C=BA?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dataSources.xml | 17 ++ .idea/encodings.xml | 2 + .idea/misc.xml | 2 +- .idea/mybatisx/templates.xml | 65 +++++++ .idea/uiDesigner.xml | 124 +++++++++++++ .idea/vcs.xml | 6 + commons/pom.xml | 17 ++ community-8073/pom.xml | 167 ++++++++++++++++++ .../java/com/ivmiku/tutorial/Main8133.java | 4 +- .../tutorial/config/SaTokenConfigure.java | 43 +++-- .../main/resources/application-dep.properties | 10 +- .../main/resources/application-dev.properties | 10 +- .../src/main/resources/application.properties | 2 +- pom.xml | 79 +++++---- .../java/com/ivmiku/tutorial/Main8072.java | 4 +- .../main/resources/application-dep.properties | 12 +- .../main/resources/application-dev.properties | 5 +- .../src/main/resources/application.properties | 2 +- 18 files changed, 510 insertions(+), 61 deletions(-) create mode 100644 .idea/dataSources.xml create mode 100644 .idea/mybatisx/templates.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 community-8073/pom.xml diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..b48c127 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,17 @@ + + + + + mysql_aurora_aws + true + software.aws.rds.jdbc.mysql.Driver + jdbc:mysql:aws://localhost:3306/tutorial + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 240ee29..c54f389 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -3,6 +3,8 @@ + + diff --git a/.idea/misc.xml b/.idea/misc.xml index fdc35ea..bada8b5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/.idea/mybatisx/templates.xml b/.idea/mybatisx/templates.xml new file mode 100644 index 0000000..47f2860 --- /dev/null +++ b/.idea/mybatisx/templates.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/commons/pom.xml b/commons/pom.xml index 1bf709a..439782d 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -27,5 +27,22 @@ com.alibaba.fastjson2 fastjson2 + + cn.hutool + hutool-all + 5.8.21 + + + + org.springframework.boot + spring-boot-starter-test + 3.1.5 + + + + io.github.openfeign + feign-micrometer + 12.5 + \ No newline at end of file diff --git a/community-8073/pom.xml b/community-8073/pom.xml new file mode 100644 index 0000000..1fc819e --- /dev/null +++ b/community-8073/pom.xml @@ -0,0 +1,167 @@ + + + 4.0.0 + + com.ivmiku.tutorial + first-tutorial + 1.0-SNAPSHOT + + + community-8073 + + + 21 + 21 + UTF-8 + + + + + + + + + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.1.0 + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.1.0 + + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + com.baomidou + mybatis-plus-spring-boot3-starter + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + provided + + + + cn.dev33 + sa-token-spring-boot3-starter + + + + com.alibaba.fastjson2 + fastjson2 + + + + cn.dev33 + sa-token-redis-jackson + 1.38.0 + + + org.apache.commons + commons-pool2 + + + + org.apache.dubbo + dubbo-spring-boot-starter + + + + org.apache.dubbo + dubbo-registry-nacos + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + io.micrometer + micrometer-tracing + + + + io.micrometer + micrometer-tracing-bridge-brave + + + + io.micrometer + micrometer-observation + + + + io.zipkin.reporter2 + zipkin-reporter-brave + + + org.apache.dubbo + dubbo-spring-boot-tracing-brave-zipkin-starter + 3.2.13 + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + com.github.binarywang + weixin-java-miniapp + + + com.ivmiku.tutorial + commons + 1.0-SNAPSHOT + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 3.0.13 + + com.ivmiku.tutorial.Main8072 + JAR + + + + + repackage + + + + + + + \ No newline at end of file diff --git a/gateway-8133/src/main/java/com/ivmiku/tutorial/Main8133.java b/gateway-8133/src/main/java/com/ivmiku/tutorial/Main8133.java index 954215d..944b565 100644 --- a/gateway-8133/src/main/java/com/ivmiku/tutorial/Main8133.java +++ b/gateway-8133/src/main/java/com/ivmiku/tutorial/Main8133.java @@ -3,7 +3,9 @@ package com.ivmiku.tutorial; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication +@SpringBootApplication(exclude = { + org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinAutoConfiguration.class +}) public class Main8133 { public static void main(String[] args) { SpringApplication.run(Main8133.class, args); diff --git a/gateway-8133/src/main/java/com/ivmiku/tutorial/config/SaTokenConfigure.java b/gateway-8133/src/main/java/com/ivmiku/tutorial/config/SaTokenConfigure.java index 59bfbdc..d26eec4 100644 --- a/gateway-8133/src/main/java/com/ivmiku/tutorial/config/SaTokenConfigure.java +++ b/gateway-8133/src/main/java/com/ivmiku/tutorial/config/SaTokenConfigure.java @@ -11,26 +11,49 @@ import org.springframework.context.annotation.Configuration; * [Sa-Token 权限认证] 配置类 * @author click33 */ +//@Configuration +//public class SaTokenConfigure { +// // 注册 Sa-Token全局过滤器 +// @Bean +// public SaReactorFilter getSaReactorFilter() { +// return new SaReactorFilter() +// // 拦截地址 +// .addInclude("/**") /* 拦截全部path */ +// // 开放地址 +// .addExclude("/favicon.ico") +// // 鉴权方法:每次访问进入 +// .setAuth(obj -> { +// // 登录校验 -- 拦截所有路由,并排除/user/doLogin 用于开放登录 +// SaRouter.match("/**", "/user/**", r -> StpUtil.checkLogin()); +// }) +// // 异常处理方法:每次setAuth函数出现异常时进入 +// .setError(e -> { +// return SaResult.error(e.getMessage()); +// }); +// } +//} @Configuration public class SaTokenConfigure { - // 注册 Sa-Token全局过滤器 + + // 注册 Sa-Token 全局过滤器 @Bean public SaReactorFilter getSaReactorFilter() { return new SaReactorFilter() // 拦截地址 - .addInclude("/**") /* 拦截全部path */ + .addInclude("/**") /* 拦截全部路径 */ // 开放地址 - .addExclude("/favicon.ico") + .addExclude("/favicon.ico", + "/user/login", + "/user/register", + "/swagger-resources/**", + "/v3/**", + "/swagger-ui/**") // 鉴权方法:每次访问进入 .setAuth(obj -> { - // 登录校验 -- 拦截所有路由,并排除/user/doLogin 用于开放登录 + // 登录校验 -- 拦截所有路由,并排除指定路由 SaRouter.match("/**", "/user/**", r -> StpUtil.checkLogin()); }) - // 异常处理方法:每次setAuth函数出现异常时进入 - .setError(e -> { - return SaResult.error(e.getMessage()); - }) - ; + // 异常处理方法:每次 setAuth 函数出现异常时进入 + .setError(e -> SaResult.error(e.getMessage())); } } - diff --git a/gateway-8133/src/main/resources/application-dep.properties b/gateway-8133/src/main/resources/application-dep.properties index 55f6029..a793f21 100644 --- a/gateway-8133/src/main/resources/application-dep.properties +++ b/gateway-8133/src/main/resources/application-dep.properties @@ -1,16 +1,16 @@ server.port=8133 spring.application.name=gateway -spring.cloud.nacos.discovery.server-addr=nacos:8848 +spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 -spring.data.redis.host=redis +spring.data.redis.host=127.0.0.1 spring.data.redis.port=6379 spring.data.redis.database=0 -spring.data.redis.password=Shuodedaoli114514 +#spring.data.redis.password=Shuodedaoli114514 spring.cloud.gateway.routes[0].id=user spring.cloud.gateway.routes[0].uri=lb://user spring.cloud.gateway.routes[0].predicates[0]=Path=/user/** -management.zipkin.tracing.endpoint=http://zipkin:9411/api/v2/spans -management.tracing.sampling.probability=1.0 \ No newline at end of file +management.zipkin.tracing.endpoint=http://127.0.0.1:9411/api/v2/spans +management.tracing.sampling.probability=1.0 diff --git a/gateway-8133/src/main/resources/application-dev.properties b/gateway-8133/src/main/resources/application-dev.properties index 12528ab..b28784a 100644 --- a/gateway-8133/src/main/resources/application-dev.properties +++ b/gateway-8133/src/main/resources/application-dev.properties @@ -10,6 +10,12 @@ spring.data.redis.database=0 spring.cloud.gateway.routes[0].id=user spring.cloud.gateway.routes[0].uri=lb://user spring.cloud.gateway.routes[0].predicates[0]=Path=/user/** +spring.cloud.gateway.routes[0].filters[0]=StripPrefix=1 -management.zipkin.tracing.endpoint=http://localhost:9411/api/v2/spans -management.tracing.sampling.probability=1.0 \ No newline at end of file +spring.cloud.gateway.routes[1].id=community +spring.cloud.gateway.routes[1].uri=lb://community +spring.cloud.gateway.routes[1].predicates[0]=Path=/community/** +spring.cloud.gateway.routes[1].filters[0]=StripPrefix=1 + +#management.zipkin.tracing.endpoint=http://localhost:9411/api/v2/spans +#management.tracing.sampling.probability=1.0 diff --git a/gateway-8133/src/main/resources/application.properties b/gateway-8133/src/main/resources/application.properties index 0896b37..257b306 100644 --- a/gateway-8133/src/main/resources/application.properties +++ b/gateway-8133/src/main/resources/application.properties @@ -1 +1 @@ -spring.profiles.active=dep \ No newline at end of file +spring.profiles.active=dev \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8db85ab..9cb51c7 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,8 @@ gateway-8133 user-8072 commons + community-8073 + @@ -24,7 +26,7 @@ 5.8.22 1.18.30 3.5.6 - 8.0.11 + 8.0.28 4.2.3 2.0.40 1.0.2 @@ -52,6 +54,37 @@ + + + mysql + mysql-connector-java + 8.0.28 + + + + javax.persistence + persistence-api + 1.0.2 + + + + + cn.hutool + hutool-all + 5.8.21 + + + + org.springframework.boot + spring-boot-starter-test + 3.1.5 + + + + io.github.openfeign + feign-micrometer + 12.5 + org.springframework.boot @@ -82,30 +115,21 @@ mybatis-plus-spring-boot3-starter ${mybatis.springboot.version} - - - mysql - mysql-connector-java - ${mysql.version} - - - - javax.persistence - persistence-api - ${persistence-api.version} - + + + + + + + + com.alibaba.fastjson2 fastjson2 ${fastjson2.version} - - - cn.hutool - hutool-all - ${hutool.version} - + org.projectlombok @@ -113,13 +137,7 @@ ${lombok.version} true - - - org.springframework.boot - spring-boot-starter-test - ${spring.boot.test.version} - test - + @@ -147,12 +165,7 @@ micrometer-observation ${micrometer-observation.version} - - - io.github.openfeign - feign-micrometer - ${feign-micrometer.version} - + io.zipkin.reporter2 @@ -184,6 +197,8 @@ weixin-java-miniapp ${wx.version} + + \ No newline at end of file diff --git a/user-8072/src/main/java/com/ivmiku/tutorial/Main8072.java b/user-8072/src/main/java/com/ivmiku/tutorial/Main8072.java index 31a15fe..817c779 100644 --- a/user-8072/src/main/java/com/ivmiku/tutorial/Main8072.java +++ b/user-8072/src/main/java/com/ivmiku/tutorial/Main8072.java @@ -4,7 +4,9 @@ import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication +@SpringBootApplication(exclude = { + org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinAutoConfiguration.class +}) @MapperScan("com.ivmiku.tutorial.mapper") public class Main8072 { public static void main(String[] args) { diff --git a/user-8072/src/main/resources/application-dep.properties b/user-8072/src/main/resources/application-dep.properties index 2e28acd..d286cee 100644 --- a/user-8072/src/main/resources/application-dep.properties +++ b/user-8072/src/main/resources/application-dep.properties @@ -1,7 +1,7 @@ wx.miniapp.configs[0].appid=wx0d4fdb5c7bf3b12b wx.miniapp.configs[0].secret=989f155fcc3aee616568473faf1b1d3b -spring.data.redis.host=redis +spring.data.redis.host=127.0.0.1 spring.data.redis.port=6379 spring.data.redis.database=0 @@ -11,11 +11,11 @@ server.port=8072 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root -spring.datasource.password=Shuodedaoli114514 -spring.datasource.url=jdbc:mysql://mysql:4514/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&ServerTimezone=Asia/Shanghai +spring.datasource.password=123456 +spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai -spring.cloud.nacos.discovery.server-addr=nacos:8848 +spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 spring.cloud.nacos.discovery.enabled=true -management.zipkin.tracing.endpoint=http://zipkin:9411/api/v2/spans -management.tracing.sampling.probability=1.0 \ No newline at end of file +management.zipkin.tracing.endpoint=http://127.0.0.1:9411/api/v2/spans +management.tracing.sampling.probability=1.0 diff --git a/user-8072/src/main/resources/application-dev.properties b/user-8072/src/main/resources/application-dev.properties index bf4864f..90fc9fb 100644 --- a/user-8072/src/main/resources/application-dev.properties +++ b/user-8072/src/main/resources/application-dev.properties @@ -11,5 +11,8 @@ server.port=8072 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root -spring.datasource.password=12345abcde +spring.datasource.password=123456 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&ServerTimezone=Asia/Shanghai + + +dubbo.application.qos-enable=false \ No newline at end of file diff --git a/user-8072/src/main/resources/application.properties b/user-8072/src/main/resources/application.properties index 0896b37..257b306 100644 --- a/user-8072/src/main/resources/application.properties +++ b/user-8072/src/main/resources/application.properties @@ -1 +1 @@ -spring.profiles.active=dep \ No newline at end of file +spring.profiles.active=dev \ No newline at end of file From 946c479d048067a260125d730aae818888f3ad64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=85=83=E7=9A=93?= Date: Thu, 8 Aug 2024 17:13:50 +0800 Subject: [PATCH 2/2] minio --- .idea/vcs.xml | 2 +- community-8073/pom.xml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/community-8073/pom.xml b/community-8073/pom.xml index 1fc819e..8d30724 100644 --- a/community-8073/pom.xml +++ b/community-8073/pom.xml @@ -24,6 +24,12 @@ + + io.minio + minio + 7.0.2 + + org.springdoc