You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/07/12 08:57:55 UTC

[servicecomb-samples] branch master updated: change website to spring boot application to make less error

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new e019d70  change website to spring boot application to make less error
e019d70 is described below

commit e019d700a52b3bb71718e998bb9ff50a028eac42
Author: liubao68 <bi...@qq.com>
AuthorDate: Sun Jul 12 16:42:26 2020 +0800

    change website to spring boot application to make less error
---
 .gitignore                                         |  3 ++
 porter_springboot/api/common/endpoint/pom.xml      |  2 +-
 porter_springboot/api/common/pom.xml               |  2 +-
 porter_springboot/api/common/service/pom.xml       |  2 +-
 .../api/file-service/endpoint/pom.xml              |  2 +-
 porter_springboot/api/file-service/pom.xml         |  2 +-
 porter_springboot/api/file-service/service/pom.xml |  2 +-
 porter_springboot/api/pom.xml                      |  2 +-
 .../api/user-service/endpoint/pom.xml              |  2 +-
 porter_springboot/api/user-service/pom.xml         |  2 +-
 porter_springboot/api/user-service/service/pom.xml |  2 +-
 porter_springboot/file-service/pom.xml             |  2 +-
 .../src/main/resources/application.yml             |  4 +-
 porter_springboot/gateway-service/pom.xml          |  2 +-
 .../porter/gateway/StaticWebpageDispatcher.java    | 52 ----------------------
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  3 +-
 .../src/main/resources/application.yml             | 12 ++++-
 porter_springboot/pom.xml                          |  7 ++-
 porter_springboot/user-service/pom.xml             |  2 +-
 porter_springboot/website/pom.xml                  | 35 +++++++++++++++
 .../samples/porter/user/WebsiteApplication.java    | 13 ++++++
 .../website/src/main/resources/application.yml     | 26 +++++++++++
 .../src/main/resources/static}/ui/css/style.css    |  0
 .../resources/static}/ui/js/jquery-1.11.1.min.js   |  0
 .../src/main/resources/static}/ui/js/login.js      |  0
 .../src/main/resources/static}/ui/js/upload.js     |  0
 .../src/main/resources/static}/ui/login.html       |  0
 .../src/main/resources/static}/ui/upload.html      |  0
 28 files changed, 109 insertions(+), 72 deletions(-)

diff --git a/.gitignore b/.gitignore
index 67e5a7d..5f448d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,3 +83,6 @@ __pycache__/
 
 # gradle
 .gradle
+
+# maven
+.versionsBackup
diff --git a/porter_springboot/api/common/endpoint/pom.xml b/porter_springboot/api/common/endpoint/pom.xml
index a20b7de..60976e7 100644
--- a/porter_springboot/api/common/endpoint/pom.xml
+++ b/porter_springboot/api/common/endpoint/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>common-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>common-api-endpoint</artifactId>
diff --git a/porter_springboot/api/common/pom.xml b/porter_springboot/api/common/pom.xml
index ad74433..71a1f6f 100644
--- a/porter_springboot/api/common/pom.xml
+++ b/porter_springboot/api/common/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>porter-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>common-api</artifactId>
diff --git a/porter_springboot/api/common/service/pom.xml b/porter_springboot/api/common/service/pom.xml
index 4693b7f..219444f 100644
--- a/porter_springboot/api/common/service/pom.xml
+++ b/porter_springboot/api/common/service/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>common-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>common-api-service</artifactId>
diff --git a/porter_springboot/api/file-service/endpoint/pom.xml b/porter_springboot/api/file-service/endpoint/pom.xml
index dbd99de..1822f4c 100644
--- a/porter_springboot/api/file-service/endpoint/pom.xml
+++ b/porter_springboot/api/file-service/endpoint/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>file-service-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>file-service-api-endpoint</artifactId>
diff --git a/porter_springboot/api/file-service/pom.xml b/porter_springboot/api/file-service/pom.xml
index e50911d..3ee1f30 100644
--- a/porter_springboot/api/file-service/pom.xml
+++ b/porter_springboot/api/file-service/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>porter-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>file-service-api</artifactId>
diff --git a/porter_springboot/api/file-service/service/pom.xml b/porter_springboot/api/file-service/service/pom.xml
index 3426ee7..89ae986 100644
--- a/porter_springboot/api/file-service/service/pom.xml
+++ b/porter_springboot/api/file-service/service/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>file-service-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>file-service-api-service</artifactId>
diff --git a/porter_springboot/api/pom.xml b/porter_springboot/api/pom.xml
index 6c064b8..919cf19 100644
--- a/porter_springboot/api/pom.xml
+++ b/porter_springboot/api/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>porter-application</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>porter-api</artifactId>
diff --git a/porter_springboot/api/user-service/endpoint/pom.xml b/porter_springboot/api/user-service/endpoint/pom.xml
index ab720b4..f7f8a0d 100644
--- a/porter_springboot/api/user-service/endpoint/pom.xml
+++ b/porter_springboot/api/user-service/endpoint/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>user-service-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>user-service-api-endpoint</artifactId>
diff --git a/porter_springboot/api/user-service/pom.xml b/porter_springboot/api/user-service/pom.xml
index ec25a31..6c8dd7d 100644
--- a/porter_springboot/api/user-service/pom.xml
+++ b/porter_springboot/api/user-service/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>porter-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>user-service-api</artifactId>
diff --git a/porter_springboot/api/user-service/service/pom.xml b/porter_springboot/api/user-service/service/pom.xml
index a332428..f1a9e55 100644
--- a/porter_springboot/api/user-service/service/pom.xml
+++ b/porter_springboot/api/user-service/service/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>user-service-api</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>user-service-api-service</artifactId>
diff --git a/porter_springboot/file-service/pom.xml b/porter_springboot/file-service/pom.xml
index 0beb917..cd754bc 100644
--- a/porter_springboot/file-service/pom.xml
+++ b/porter_springboot/file-service/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>porter-application</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>porter-file-service</artifactId>
diff --git a/porter_springboot/file-service/src/main/resources/application.yml b/porter_springboot/file-service/src/main/resources/application.yml
index c1f0727..72868ee 100644
--- a/porter_springboot/file-service/src/main/resources/application.yml
+++ b/porter_springboot/file-service/src/main/resources/application.yml
@@ -17,7 +17,7 @@
 ## ---------------------------------------------------------------------------
 # spring boot configurations
 server:
-  port: 9091  # should be same with servicecomb.rest.address to use web container
+  port: 9092  # should be same with servicecomb.rest.address to use web container
 
 # override common configurations in common module
 servicecomb-config-order: 10
@@ -36,7 +36,7 @@ servicecomb:
         watch: false
 
   rest:
-    address: 0.0.0.0:9091  # should be same with server.port to use web container
+    address: 0.0.0.0:9092  # should be same with server.port to use web container
 
   uploads:
     directory: tmp_for_upload_file
diff --git a/porter_springboot/gateway-service/pom.xml b/porter_springboot/gateway-service/pom.xml
index 91bf4a3..5bc3262 100644
--- a/porter_springboot/gateway-service/pom.xml
+++ b/porter_springboot/gateway-service/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>porter-application</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>porter-gateway-service</artifactId>
diff --git a/porter_springboot/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java b/porter_springboot/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
deleted file mode 100644
index 791c512..0000000
--- a/porter_springboot/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.samples.porter.gateway;
-
-import org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.netflix.config.DynamicPropertyFactory;
-
-import io.vertx.ext.web.Router;
-import io.vertx.ext.web.handler.StaticHandler;
-
-public class StaticWebpageDispatcher implements VertxHttpDispatcher {
-  private static final Logger LOGGER = LoggerFactory.getLogger(StaticWebpageDispatcher.class);
-
-  private static final String WEB_ROOT = DynamicPropertyFactory.getInstance()
-      .getStringProperty("gateway.webroot", "/var/static")
-      .get();
-
-  @Override
-  public int getOrder() {
-    return Integer.MAX_VALUE;
-  }
-
-  @Override
-  public void init(Router router) {
-    String regex = "/ui/(.*)";
-    StaticHandler webpageHandler = StaticHandler.create();
-    webpageHandler.setWebRoot(WEB_ROOT);
-    LOGGER.info("server static web page for WEB_ROOT={}", WEB_ROOT);
-    router.routeWithRegex(regex).failureHandler((context) -> {
-      LOGGER.error("", context.failure());
-    }).handler(webpageHandler);
-  }
-
-}
diff --git a/porter_springboot/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/porter_springboot/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index 71009db..709c4e5 100644
--- a/porter_springboot/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/porter_springboot/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -15,5 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
-org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
\ No newline at end of file
+org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
\ No newline at end of file
diff --git a/porter_springboot/gateway-service/src/main/resources/application.yml b/porter_springboot/gateway-service/src/main/resources/application.yml
index 58a668a..1c305c5 100644
--- a/porter_springboot/gateway-service/src/main/resources/application.yml
+++ b/porter_springboot/gateway-service/src/main/resources/application.yml
@@ -58,8 +58,16 @@ servicecomb:
       edge:
         default:
           enabled: false
-      rest:
-        pattern: '[/v1/log/|/inspector](.*)'
+        http:
+          enabled: true
+          pattern: /ui/(.*)
+          mappings:
+            website:
+              prefixSegmentCount: 0
+              path: "/ui/.*"
+              microserviceName: website
+              versionRule: 0.0.0+
+
 
 # This is web root for windows server, change this path according to where you put your source code
 gateway:
diff --git a/porter_springboot/pom.xml b/porter_springboot/pom.xml
index e238822..178702a 100644
--- a/porter_springboot/pom.xml
+++ b/porter_springboot/pom.xml
@@ -22,7 +22,7 @@
 
   <groupId>org.apache.servicecomb.samples.porter</groupId>
   <artifactId>porter-application</artifactId>
-  <version>2.0.0</version>
+  <version>2.1.0</version>
   <packaging>pom</packaging>
 
   <properties>
@@ -62,6 +62,10 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
   </dependencies>
 
   <modules>
@@ -69,6 +73,7 @@
     <module>file-service</module>
     <module>user-service</module>
     <module>gateway-service</module>
+    <module>website</module>
   </modules>
 
   <build>
diff --git a/porter_springboot/user-service/pom.xml b/porter_springboot/user-service/pom.xml
index 28fe838..abcb430 100644
--- a/porter_springboot/user-service/pom.xml
+++ b/porter_springboot/user-service/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
     <artifactId>porter-application</artifactId>
-    <version>2.0.0</version>
+    <version>2.1.0</version>
   </parent>
 
   <artifactId>porter-user-service</artifactId>
diff --git a/porter_springboot/website/pom.xml b/porter_springboot/website/pom.xml
new file mode 100644
index 0000000..a6ce174
--- /dev/null
+++ b/porter_springboot/website/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <groupId>org.apache.servicecomb.samples.porter</groupId>
+    <artifactId>porter-application</artifactId>
+    <version>2.1.0</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>porter-website</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/porter_springboot/website/src/main/java/org/apache/servicecomb/samples/porter/user/WebsiteApplication.java b/porter_springboot/website/src/main/java/org/apache/servicecomb/samples/porter/user/WebsiteApplication.java
new file mode 100644
index 0000000..3697a89
--- /dev/null
+++ b/porter_springboot/website/src/main/java/org/apache/servicecomb/samples/porter/user/WebsiteApplication.java
@@ -0,0 +1,13 @@
+package org.apache.servicecomb.samples.porter.user;
+
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableServiceComb
+public class WebsiteApplication {
+  public static void main(String[] args) throws Exception {
+    SpringApplication.run(WebsiteApplication.class, args);
+  }
+}
diff --git a/porter_springboot/website/src/main/resources/application.yml b/porter_springboot/website/src/main/resources/application.yml
new file mode 100644
index 0000000..01d7218
--- /dev/null
+++ b/porter_springboot/website/src/main/resources/application.yml
@@ -0,0 +1,26 @@
+## Spring Boot configurations
+server:
+  port: 9091
+  # servlet.path: /
+
+APPLICATION_ID: porter-application
+service_description:
+  version: 0.0.1
+  name: website
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9091 # should be same with server.port to use web container
+    ## static web site will token root
+    servlet:
+      urlPattern: /api/*
+
+  metrics:
+    publisher.defaultLog:
+      enabled: false
diff --git a/porter_springboot/gateway-service/src/main/resources/ui/css/style.css b/porter_springboot/website/src/main/resources/static/ui/css/style.css
similarity index 100%
rename from porter_springboot/gateway-service/src/main/resources/ui/css/style.css
rename to porter_springboot/website/src/main/resources/static/ui/css/style.css
diff --git a/porter_springboot/gateway-service/src/main/resources/ui/js/jquery-1.11.1.min.js b/porter_springboot/website/src/main/resources/static/ui/js/jquery-1.11.1.min.js
similarity index 100%
rename from porter_springboot/gateway-service/src/main/resources/ui/js/jquery-1.11.1.min.js
rename to porter_springboot/website/src/main/resources/static/ui/js/jquery-1.11.1.min.js
diff --git a/porter_springboot/gateway-service/src/main/resources/ui/js/login.js b/porter_springboot/website/src/main/resources/static/ui/js/login.js
similarity index 100%
rename from porter_springboot/gateway-service/src/main/resources/ui/js/login.js
rename to porter_springboot/website/src/main/resources/static/ui/js/login.js
diff --git a/porter_springboot/gateway-service/src/main/resources/ui/js/upload.js b/porter_springboot/website/src/main/resources/static/ui/js/upload.js
similarity index 100%
rename from porter_springboot/gateway-service/src/main/resources/ui/js/upload.js
rename to porter_springboot/website/src/main/resources/static/ui/js/upload.js
diff --git a/porter_springboot/gateway-service/src/main/resources/ui/login.html b/porter_springboot/website/src/main/resources/static/ui/login.html
similarity index 100%
rename from porter_springboot/gateway-service/src/main/resources/ui/login.html
rename to porter_springboot/website/src/main/resources/static/ui/login.html
diff --git a/porter_springboot/gateway-service/src/main/resources/ui/upload.html b/porter_springboot/website/src/main/resources/static/ui/upload.html
similarity index 100%
rename from porter_springboot/gateway-service/src/main/resources/ui/upload.html
rename to porter_springboot/website/src/main/resources/static/ui/upload.html