add a basic sample for use (#67)
diff --git a/README.md b/README.md
index 0ae0dc2..913c93f 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,9 @@
This project is samples for java-chassis 2.0.x. You can switch to other branches to see different samples.
+## basic
+A sample shows a provider, a consumer and a gateway using java chassis.
+
## porter_lightweight
A sample shows an application with basic login, download file, delete file functions. Read this [document](https://docs.servicecomb.io/java-chassis/zh_CN/featured-topics/application-porter/) for details.
@@ -15,6 +18,9 @@
这个项目使用java-chassis 2.0.x版本。可以切换分支,查看其他版本的例子。
+## basic
+该项目展示了Java Chassis开发的一个provider, 一个consumer和一个网关服务。
+
## porter_lightweight
该项目演示了一个包括网关、文件下载、认证鉴权等功能的简单应用系统,同时演示了ServiceComb推荐的先写接口声明,再写业务代码的软件工程实践。可以阅读[文章](https://docs.servicecomb.io/java-chassis/zh_CN/featured-topics/application-porter/)了解项目的细节。这个例子的运行环境采用vert.x作为HTTP服务器,即 REST
over Vert.x transport。
diff --git a/basic/README.md b/basic/README.md
new file mode 100644
index 0000000..45ff3a9
--- /dev/null
+++ b/basic/README.md
@@ -0,0 +1,32 @@
+# Description
+This project providers sample to show working with Java Chassis Microservices.
+
+* provider
+A Microserivce using Java Chassis with a REST interface.
+
+* consumer
+A Microserivce using Java Chassis with a REST interface. Consumer calls provider with RPC.
+
+* gateway
+A Microserivce using Java Chassis Edge Service to forward requests to consumer.
+
+# Usage
+Start 3 microservices and open in browser: http://localhost:9090/sayHello?name=World
+
+
+# 项目说明
+
+这个项目提供了 Java Chassis 的简单例子,例子包括:
+
+* provider
+使用 Java Chassis 开发一个 REST 接口。
+
+* consumer
+使用 Java Chassis 开发一个 REST 接口, 接口实现通过 RPC 调用 provider 的接口。
+
+* gateway
+使用 Java Chassis Edge Service 开发一个网关, 网关将所有请求转发到 consumer。
+
+## 使用
+
+启动3个微服务, 然后通过界面访问: http://localhost:9090/sayHello?name=World
diff --git a/basic/consumer/pom.xml b/basic/consumer/pom.xml
new file mode 100644
index 0000000..2407914
--- /dev/null
+++ b/basic/consumer/pom.xml
@@ -0,0 +1,46 @@
+<!--
+ ~ 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.
+ -->
+
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicecomb.samples</groupId>
+ <artifactId>basic-application</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>basic-consumer</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.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/basic/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerApplication.java b/basic/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerApplication.java
new file mode 100644
index 0000000..b66c992
--- /dev/null
+++ b/basic/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerApplication.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableServiceComb
+public class ConsumerApplication {
+ public static void main(String[] args) throws Exception {
+ try {
+ SpringApplication.run(ConsumerApplication.class, args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/basic/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerController.java b/basic/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerController.java
new file mode 100644
index 0000000..700fae0
--- /dev/null
+++ b/basic/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerController.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "ConsumerController")
+@RequestMapping(path = "/")
+public class ConsumerController {
+ @RpcReference(schemaId = "ProviderController", microserviceName = "provider")
+ private ProviderService providerService;
+
+ @GetMapping("/sayHello")
+ public String sayHello(@RequestParam("name") String name) {
+ return providerService.sayHello(name);
+ }
+}
diff --git a/basic/consumer/src/main/java/org/apache/servicecomb/samples/ProviderService.java b/basic/consumer/src/main/java/org/apache/servicecomb/samples/ProviderService.java
new file mode 100644
index 0000000..f327412
--- /dev/null
+++ b/basic/consumer/src/main/java/org/apache/servicecomb/samples/ProviderService.java
@@ -0,0 +1,22 @@
+/*
+ * 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;
+
+public interface ProviderService {
+ String sayHello(String name);
+}
diff --git a/basic/consumer/src/main/resources/application.yml b/basic/consumer/src/main/resources/application.yml
new file mode 100644
index 0000000..01249ce
--- /dev/null
+++ b/basic/consumer/src/main/resources/application.yml
@@ -0,0 +1,52 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+# spring boot configurations
+server:
+ port: 9092 # should be same with servicecomb.rest.address to use web container
+
+# override common configurations in common module
+servicecomb-config-order: 10
+
+servicecomb:
+ service:
+ application: basic-application
+ name: consumer
+ version: 0.0.1
+ registry:
+ # Default using local service center
+ address: http://localhost:30100
+ # address: https://cse.cn-south-1.myhuaweicloud.com
+ instance:
+ watch: false
+ config:
+ client:
+ # Default using local config center
+ # serverUri: https://cse.cn-south-1.myhuaweicloud.com
+ serverUri: http://localhost:30113
+ refreshMode: 1
+
+ rest:
+ address: 0.0.0.0:9092 # should be same with server.port to use web container
+
+# Using Huawei Cloud Service Engine Professional Edition, AK/SK is required
+# credentials:
+# akskEnabled: true
+# accessKey: add your ak/sk from huaweicloud
+# secretKey: add your ak/sk from huaweicloud
+# akskCustomCipher: default
+# project: cn-south-1
\ No newline at end of file
diff --git a/basic/consumer/src/main/resources/log4j2.xml b/basic/consumer/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..313d1fc
--- /dev/null
+++ b/basic/consumer/src/main/resources/log4j2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!--this is sample configuration, please modify as your wish -->
+
+<configuration>
+ <Properties>
+ <Property name="log_path">./file/log/</Property>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
+ </Console>
+ <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+ filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+ <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
+ <Policies>
+ <TimeBasedTriggeringPolicy interval="1" />
+ <SizeBasedTriggeringPolicy size="10 MB" />
+ </Policies>
+ </RollingFile>
+ </Appenders>
+ <Loggers>
+ <Root level="info">
+ <AppenderRef ref="Console" />
+ <AppenderRef ref="DailyRollingFile" />
+ </Root>
+ </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/basic/gateway/pom.xml b/basic/gateway/pom.xml
new file mode 100644
index 0000000..613c99b
--- /dev/null
+++ b/basic/gateway/pom.xml
@@ -0,0 +1,49 @@
+<!--
+ ~ 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.
+ -->
+
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicecomb.samples</groupId>
+ <artifactId>basic-application</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>basic-gateway</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>edge-core</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/basic/gateway/src/main/java/org/apache/servicecomb/samples/GatewayApplication.java b/basic/gateway/src/main/java/org/apache/servicecomb/samples/GatewayApplication.java
new file mode 100644
index 0000000..f2e086b
--- /dev/null
+++ b/basic/gateway/src/main/java/org/apache/servicecomb/samples/GatewayApplication.java
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+@SpringBootApplication
+@EnableServiceComb
+public class GatewayApplication {
+ public static void main(String[] args) throws Exception {
+ try {
+ new SpringApplicationBuilder().web(WebApplicationType.NONE).sources(GatewayApplication.class).run(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/basic/gateway/src/main/resources/application.yml b/basic/gateway/src/main/resources/application.yml
new file mode 100644
index 0000000..7ed512d
--- /dev/null
+++ b/basic/gateway/src/main/resources/application.yml
@@ -0,0 +1,64 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+servicecomb:
+ service:
+ application: basic-application
+ name: gateway
+ version: 0.0.1
+ registry:
+ # Default using local service center
+ address: http://localhost:30100
+ # address: https://cse.cn-south-1.myhuaweicloud.com
+ instance:
+ watch: false
+ config:
+ client:
+ # Default using local config center
+ # serverUri: https://cse.cn-south-1.myhuaweicloud.com
+ serverUri: http://localhost:30113
+ refreshMode: 1
+
+ rest:
+ address: 0.0.0.0:9090?sslEnabled=false
+
+ http:
+ dispatcher:
+ edge:
+ default:
+ enabled: false
+ url:
+ enabled: true
+ pattern: /(.*)
+ mappings:
+ consumer:
+ prefixSegmentCount: 0
+ path: "/.*"
+ microserviceName: consumer
+ versionRule: 0.0.0+
+
+# Using Huawei Cloud Service Engine Professional Edition, AK/SK is required
+# credentials:
+# akskEnabled: true
+# accessKey: add your ak/sk from huaweicloud
+# secretKey: add your ak/sk from huaweicloud
+# akskCustomCipher: default
+# project: cn-south-1
diff --git a/basic/gateway/src/main/resources/log4j2.xml b/basic/gateway/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..e9bb265
--- /dev/null
+++ b/basic/gateway/src/main/resources/log4j2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!--this is sample configuration, please modify as your wish -->
+
+<configuration>
+ <Properties>
+ <Property name="log_path">./gateway/log/</Property>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
+ </Console>
+ <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+ filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+ <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
+ <Policies>
+ <TimeBasedTriggeringPolicy interval="1" />
+ <SizeBasedTriggeringPolicy size="10 MB" />
+ </Policies>
+ </RollingFile>
+ </Appenders>
+ <Loggers>
+ <Root level="info">
+ <AppenderRef ref="Console" />
+ <AppenderRef ref="DailyRollingFile" />
+ </Root>
+ </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/basic/pom.xml b/basic/pom.xml
new file mode 100644
index 0000000..bfc4b01
--- /dev/null
+++ b/basic/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.servicecomb.samples</groupId>
+ <artifactId>basic-application</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <servicecomb.version>2.1.5</servicecomb.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-dependencies</artifactId>
+ <version>${servicecomb.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>solution-basic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>registry-service-center</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>servicestage-environment</artifactId>
+ </dependency>
+ </dependencies>
+
+ <modules>
+ <module>provider</module>
+ <module>consumer</module>
+ <module>gateway</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ <compilerArgument>-parameters</compilerArgument>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>2.1.6.RELEASE</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ <configuration>
+ <mainClass>${main.class}</mainClass>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
\ No newline at end of file
diff --git a/basic/provider/pom.xml b/basic/provider/pom.xml
new file mode 100644
index 0000000..846d5a3
--- /dev/null
+++ b/basic/provider/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicecomb.samples</groupId>
+ <artifactId>basic-application</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>basic-provider</artifactId>
+ <packaging>jar</packaging>
+
+ <properties>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/basic/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java b/basic/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java
new file mode 100644
index 0000000..b52efe4
--- /dev/null
+++ b/basic/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableServiceComb
+public class ProviderApplication {
+ public static void main(String[] args) throws Exception {
+ try {
+ SpringApplication.run(ProviderApplication.class, args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/basic/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java b/basic/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java
new file mode 100644
index 0000000..67a07c1
--- /dev/null
+++ b/basic/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "ProviderController")
+@RequestMapping(path = "/")
+public class ProviderController {
+ @GetMapping("/sayHello")
+ public String sayHello(@RequestParam("name") String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/basic/provider/src/main/resources/application.yml b/basic/provider/src/main/resources/application.yml
new file mode 100644
index 0000000..3c85cea
--- /dev/null
+++ b/basic/provider/src/main/resources/application.yml
@@ -0,0 +1,52 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+# spring boot configurations
+server:
+ port: 9093 # should be same with servicecomb.rest.address to use web container
+
+# override common configurations in common module
+servicecomb-config-order: 10
+
+servicecomb:
+ service:
+ application: basic-application
+ name: provider
+ version: 0.0.1
+ registry:
+ # Default using local service center
+ address: http://localhost:30100
+ # address: https://cse.cn-south-1.myhuaweicloud.com
+ instance:
+ watch: false
+ config:
+ client:
+ # Default using local config center
+ # serverUri: https://cse.cn-south-1.myhuaweicloud.com
+ serverUri: http://localhost:30113
+ refreshMode: 1
+
+ rest:
+ address: 0.0.0.0:9093 # should be same with server.port to use web container
+
+# Using Huawei Cloud Service Engine Professional Edition, AK/SK is required
+# credentials:
+# akskEnabled: true
+# accessKey: add your ak/sk from huaweicloud
+# secretKey: add your ak/sk from huaweicloud
+# akskCustomCipher: default
+# project: cn-south-1
\ No newline at end of file
diff --git a/basic/provider/src/main/resources/log4j2.xml b/basic/provider/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..56fc9a0
--- /dev/null
+++ b/basic/provider/src/main/resources/log4j2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!--this is sample configuration, please modify as your wish -->
+
+<configuration>
+ <Properties>
+ <Property name="log_path">./user/log/</Property>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
+ </Console>
+ <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+ filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+ <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
+ <Policies>
+ <TimeBasedTriggeringPolicy interval="1" />
+ <SizeBasedTriggeringPolicy size="10MB" />
+ </Policies>
+ </RollingFile>
+ </Appenders>
+ <Loggers>
+ <Root level="info">
+ <AppenderRef ref="Console" />
+ <AppenderRef ref="DailyRollingFile" />
+ </Root>
+ </Loggers>
+</configuration>
\ No newline at end of file