Bläddra i källkod

update version
remove zuul
add spring gateway

Mr.qian 2 dagar sedan
förälder
incheckning
7d174729c5

+ 54 - 7
operating-service/pom.xml

@@ -31,6 +31,7 @@
         <dependency>
             <groupId>org.apache.rocketmq</groupId>
             <artifactId>rocketmq-spring-boot-starter</artifactId>
+            <version>2.2.2</version>
         </dependency>
 
 
@@ -49,13 +50,6 @@
             <version>1.0.0-SNAPSHOT</version>
         </dependency>
 
-        <!--test依赖-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-
         <!--异维科技公共包依赖-->
         <dependency>
             <groupId>com.txz</groupId>
@@ -117,6 +111,59 @@
             <artifactId>httpclient</artifactId>
             <version>4.5.13</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-serialization-kryo</artifactId>
+            <version>2.7.9</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springdoc</groupId>
+            <artifactId>springdoc-openapi-ui</artifactId>
+            <version>1.6.14</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.13.2</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2.2.9.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+            <version>2.2.9.RELEASE</version>
+        </dependency>
+
+         <dependency>
+            <groupId>com.alibaba.nacos</groupId>
+            <artifactId>nacos-client</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 1 - 1
operating-service/src/main/java/com/txz/operating/OperatingApplication.java

@@ -18,7 +18,7 @@ import org.springframework.web.client.RestTemplate;
 
 @EnableDiscoveryClient
 @SpringBootApplication
-@EnableSwagger2Doc
+// @EnableSwagger2Doc
 //@RibbonClients(value = {
 //        @RibbonClient(name = "operating",configuration = RibbonWeightedResponseTimeRuleConfig.class)
 //})

+ 32 - 51
operating-service/src/main/java/com/txz/operating/configurer/SwaggerConfig.java

@@ -1,65 +1,46 @@
 package com.txz.operating.configurer;
 
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import io.swagger.v3.oas.models.parameters.Parameter;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.ParameterBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.schema.ModelRef;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.Contact;
-import springfox.documentation.service.Parameter;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * @author Fcx
  */
 @Configuration
-@EnableSwagger2
-@Profile({"dev","test"})
+@Profile({"dev", "test"})
 public class SwaggerConfig {
-
+    
     @Bean
-    public Docket docket(){
-        //添加header参数
-        List<Parameter> pars = new ArrayList<>();
-        ParameterBuilder ticketPar = new ParameterBuilder();
-        ticketPar.name("token").description("user token")
-                .modelRef(new ModelRef("string")).parameterType("header")
-                .required(false).build(); //header中的ticket参数非必填,传空也可以
-        ticketPar = new ParameterBuilder();
-        ticketPar.name("appCode").description("appCode")
-                .modelRef(new ModelRef("string")).parameterType("header")
-                .required(false).build(); //header中的ticket参数非必填,传空也可以
-
-        pars.add(ticketPar.build());
-        return new Docket(DocumentationType.SWAGGER_2)
-                .globalOperationParameters(pars)
-                .groupName("demo")
-                .apiInfo(getApiInfo())
-                .select()
-                //设置basePackage会将包下的所有被@Api标记类的所有方法作为api
-                .apis(RequestHandlerSelectors.basePackage("com.txz.operating.controller"))
-                //只有标记了@ApiOperation的方法才会暴露出给swagger
-                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
-                .paths(PathSelectors.regex("/api/.*")).build();
+    public OpenAPI customOpenAPI() {
+        return new OpenAPI()
+                .components(new Components()
+                        .addParameters("token", new Parameter()
+                                .name("token")
+                                .description("user token")
+                                .required(false)
+                                .in("header"))
+                        .addParameters("appCode", new Parameter()
+                                .name("appCode")
+                                .description("appCode")
+                                .required(false)
+                                .in("header")))
+                .info(new Info()
+                        .title("API接口文档")
+                        .description("swagger2 demo api")
+                        .version("1.0")
+                        .contact(new Contact()
+                                .name("admin")
+                                .url("http://localhost/swagger-ui.html")
+                                .email("xxx@qq.com"))
+                        .license(new License()
+                                .name("Apache 2.0")
+                                .url("http://localhost/swagger-ui.html")));
     }
-
-    private ApiInfo getApiInfo(){
-        return new ApiInfoBuilder()
-                .title("API接口文档")
-                .description("swagger2 demo api")
-                .termsOfServiceUrl("http://localhost/swagger-ui.html")
-                .version("1.0").contact(new Contact("admin", "http://localhost/swagger-ui.html", "xxx@qq.com"))
-                .build();
-    }
-
 }

+ 14 - 14
operating-service/src/main/java/com/txz/operating/configurer/shutdown/UndertowExtraConfiguration.java

@@ -11,17 +11,17 @@ import org.springframework.stereotype.Component;
  * @Date: 2019/11/29 15:13
  * @Version 1.0
  */
-@Component
-@AllArgsConstructor
-public class UndertowExtraConfiguration {
-
-    private final GracefulShutdownUndertowWrapper gracefulShutdownWrapper;
-
-    @Bean
-    public UndertowServletWebServerFactory servletWebServerFactory() {
-        UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
-        factory.addDeploymentInfoCustomizers(deploymentInfo -> deploymentInfo.addOuterHandlerChainWrapper(gracefulShutdownWrapper));
-        factory.addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_STATISTICS, true));
-        return factory;
-    }
-}
+// @Component
+// @AllArgsConstructor
+// public class UndertowExtraConfiguration {
+//
+//     private final GracefulShutdownUndertowWrapper gracefulShutdownWrapper;
+//
+//     @Bean
+//     public UndertowServletWebServerFactory servletWebServerFactory() {
+//         UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
+//         factory.addDeploymentInfoCustomizers(deploymentInfo -> deploymentInfo.addOuterHandlerChainWrapper(gracefulShutdownWrapper));
+//         factory.addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_STATISTICS, true));
+//         return factory;
+//     }
+// }

+ 22 - 16
operating-service/src/main/resources/bootstrap.properties

@@ -27,37 +27,43 @@ spring.cloud.nacos.config.server-addr=${${spring.profiles.active}.nacos}
 #\u6307\u5B9A\u914D\u7F6E\u7FA4\u7EC4 --\u5982\u679C\u662FPublic\u547D\u540D\u7A7A\u95F4 \u5219\u53EF\u4EE5\u7701\u7565\u7FA4\u7EC4\u914D\u7F6E
 #spring.cloud.nacos.config.group=dev
 #\u6587\u4EF6\u540D -- \u5982\u679C\u6CA1\u6709\u914D\u7F6E\u5219\u9ED8\u8BA4\u4E3A ${spring.appliction.name}
-spring.cloud.nacos.config.prefix=${spring.application.name}
-spring.cloud.nacos.config.file-extension=properties
+#spring.cloud.nacos.config.prefix=${spring.application.name}
+#spring.cloud.nacos.config.file-extension=properties
 
-spring.cloud.nacos.config.ext-config[0].data-id=mq-${spring.profiles.active}.properties
-spring.cloud.nacos.config.ext-config[0].refresh=true
-spring.cloud.nacos.config.ext-config[1].data-id=redis-${spring.profiles.active}.properties
-spring.cloud.nacos.config.ext-config[1].refresh=true
+spring.main.allow-circular-references=true
+springfox.documentation.enabled=false
+#spring.cloud.nacos.config.ext-config[0].data-id=mq-${spring.profiles.active}.properties
+#spring.cloud.nacos.config.ext-config[0].refresh=true
+#spring.cloud.nacos.config.ext-config[1].data-id=redis-${spring.profiles.active}.properties
+#spring.cloud.nacos.config.ext-config[1].refresh=true
+spring.cloud.nacos.config.extension-configs[0]=mq-${spring.profiles.active}.properties
+spring.cloud.nacos.config.extension-configs[1]=redis-${spring.profiles.active}.properties
+spring.cloud.nacos.config.extension-configs[2]=${spring.application.name}-${spring.profiles.active}.properties
 #spring.cloud.nacos.config.ext-config[2].data-id=cos-${spring.profiles.active}.properties
 #spring.cloud.nacos.config.ext-config[2].refresh=true
 dubbo.protocol.serialization=kryo
-#dubbo.protocol.serialization=
 dubbo.protocol.optimizer=
+dubbo.registry.register=false
 dubbo.protocol.name=dubbo
 dubbo.protocol.port=-1
 dubbo.registry.address=nacos://${${spring.profiles.active}.nacos}
 dubbo.scan.base-packages=com.txz.${spring.application.name}.dubbo.impl
-#dubbo.cloud.subscribed-services=cif
-dubbo.application.qos.enable=true
-dubbo.application.qos.port=28201
-dubbo.application.qos.accept.foreign.ip=true
+dubbo.cloud.subscribed-services=
+dubbo.application.qos.enable=false
+dubbo.application.qos.port=28111
+dubbo.application.qos.accept.foreign.ip=false
 
 dubbo.reference.com.foo.BarService.check=false
 dubbo.reference.check=false
 dubbo.consumer.check=false
 dubbo.registry.check=false
 
-management.endpoints.web.exposure.include=*
-management.endpoint.shutdown.enabled=true
-management.endpoints.web.base-path=/${spring.application.name}
-management.endpoints.web.path-mapping.shutdown=/shutThisBoot
-management.server.address=127.0.0.1
+#management.endpoints.web.exposure.include=*
+#management.endpoint.shutdown.enabled=true
+#management.endpoints.web.base-path=/${spring.application.name}
+#management.endpoints.web.path-mapping.shutdown=/shutThisBoot
+#management.server.address=127.0.0.1
+#management.server.port=8302
 
 
 #minio

+ 1 - 0
operating-service/src/test/java/com/Test1111.java

@@ -1,5 +1,6 @@
 package com;
 
+
 import org.junit.Test;
 
 /**

+ 10 - 21
pom.xml

@@ -10,9 +10,6 @@
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.7.18</version>
     </parent>
-    <properties>
-        <spring-cloud-alibaba.version>2023.0.3.3</spring-cloud-alibaba.version>
-    </properties>
 
 
     <artifactId>operating</artifactId>
@@ -28,27 +25,19 @@
             <dependency>
                 <groupId>org.springframework.cloud</groupId>
                 <artifactId>spring-cloud-dependencies</artifactId>
-                <version>Finchley.SR1</version>
+                <version>2021.0.8</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
-            <dependency>
-                <groupId>org.springframework.cloud</groupId>
-                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
-                <version>0.2.2.RELEASE</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>com.alibaba.cloud</groupId>
-                <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
-                <version>${spring-cloud-alibaba.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>com.alibaba.cloud</groupId>
-                <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-                <version>${spring-cloud-alibaba.version}</version>
-            </dependency>
+            <!-- <dependency> -->
+            <!--     <groupId>org.springframework.cloud</groupId> -->
+            <!--     <artifactId>spring-cloud-alibaba-dependencies</artifactId> -->
+            <!--     <version>0.2.2.RELEASE</version> -->
+            <!--     <type>pom</type> -->
+            <!--     <scope>import</scope> -->
+            <!-- </dependency> -->
+
+
         </dependencies>
     </dependencyManagement>
     <distributionManagement>