Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ef119d6
upgrade servicecomb version to 3.2.4
Aithosa Feb 15, 2025
731030f
upgrade `java-chassis-samples` servicecomb version to 3.2.4
Aithosa Feb 17, 2025
4ade7aa
update log file paths for consistency across modules
Aithosa Feb 21, 2025
faf8c9f
Update README
Aithosa Feb 24, 2025
c274abd
Update README with Local-CSE download option
Aithosa Jan 14, 2026
d9be7e7
Fix indentation and update registry config in microservice.yaml
Aithosa Jan 14, 2026
db7fa0d
Clarify file upload and deletion steps in README
Aithosa Jan 14, 2026
8eafea9
Modify the spelling error in the field to avoid runtime failures
Aithosa Jan 14, 2026
71fc495
Improve README formatting and consistency across examples
Aithosa Jan 19, 2026
3cfefb5
Refactor local-service-registry module:
Aithosa Jan 20, 2026
c92db24
Refactor MySqlHealthChecker and improve README formatting:
Aithosa Jan 20, 2026
96807c8
Improve README formatting and standardize structure in pojo-sample
Aithosa Jan 20, 2026
32745bd
Standardize README formatting and enhance clarity in springmvc-sample
Aithosa Jan 20, 2026
566abcb
Enhance README structure and clarity for trust-sample
Aithosa Jan 20, 2026
8703afd
Add Log4j2 logging example and enhance README in use-log4j2-sample
Aithosa Jan 20, 2026
89f8533
Fix log error and switch to Log4j 2.x
Aithosa Jan 20, 2026
d34a939
enhance README in config-apollo-sample
Aithosa Jan 20, 2026
ad7239d
enhance README in custom-handler-sample
Aithosa Jan 20, 2026
e5636b0
Delete useless dependency in trust-sample
Aithosa Jan 20, 2026
6a14994
Refactor: Use Filter instead of Handler for custom processing
Aithosa Jan 20, 2026
56919ab
Update java version to 17 in pom files.
Aithosa Jan 20, 2026
b4dc3fc
Remove redundant pom properties and adapt code for Java 17 compatibility
Aithosa Jan 21, 2026
6042f8b
Add APM Agent sample README
Aithosa Jan 21, 2026
c513998
Update README with additional event types and descriptions
Aithosa Jan 22, 2026
f3ee3cb
Refactor APM output generators and remove BootListener SPI
Aithosa Jan 22, 2026
337a785
Update README and pom.xml for Java 17 and SLF4J 2.x
Aithosa Jan 22, 2026
112bed4
Add legacy WAR sample with ServiceComb integration
Aithosa Jan 22, 2026
74311ac
Migrate metrics write-file sample to ServiceComb 3.x
Aithosa Jan 23, 2026
62eb764
Add rolling file appenders to log4j2 configs
Aithosa Jan 26, 2026
f3745ef
Upgrade servicecomb version to 3.3.0
Aithosa Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 99 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,125 @@
# ServiceComb samples

## Description

This project is samples for java-chassis 3.x.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.
## subprojects

## porter_lightweight
A sample shows an application with basic login, download file, delete file functions. Read this [document](https://servicecomb.apache.org/references/java-chassis/zh_CN/featured-topics/application-porter.html) for details.
### basic

## porter_springboot
A sample shows an application with basic login, download file, delete file functions. Read this [document](https://servicecomb.apache.org/references/java-chassis/zh_CN/featured-topics/application-porter.html) for details.
A sample shows a provider, a consumer and a gateway using java chassis.

### basic-tomcat

A sample shows a provider, a consumer and a gateway using java chassis.
While provider and consumer are packaged as WAR and deploy in tomcat.

### bmi

A sample microservices application that demonstrates BMI (Body Mass Index) calculation,
consisting of a calculator service and a web interface service with gateway capabilities.
This example shows how to build and connect microservices in a practical scenario.

### java-chassis-deployment-samples

A collection of deployment samples demonstrating how to deploy java-chassis applications in external web containers,
including Spring Boot and traditional WAR deployments.

### java-chassis-interoprability

A demonstration of interoperability between Spring Cloud and Java Chassis frameworks,
featuring a Spring Cloud Gateway with cross-framework service invocations
using both ServiceComb and Nacos service registries.

### porter

A sample shows an application with basic login, download file, delete file functions.
Read
this [document](https://servicecomb.apache.org/references/java-chassis/zh_CN/featured-topics/application-porter.html)
for details.

### java-chassis-samples

## java-chassis-samples
Featured samples for java-chassis modules. Each module contains 10 minutes guides.

## java-chassis-integration-tests
java-chassis integration tests。
### java-chassis-integration-tests

java-chassis integration tests。

> Please refer to the version in `servicecomb-java-chassis` as the primary reference.

### java-chassis-benchmark

The benchmark data compares three RESTful frameworks
(Dubbo 3.2.11, Spring Cloud 2022.0.x, and ServiceComb Java-Chassis 3.0.1) under various test conditions:
different payload sizes (1/100/1000), waiting times (0/10/100ms), with 10 threads and 1000 executions.
Historical data from previous tests (2023-12-5, 2023-11-16)
includes comparisons with different versions and JDK 8 environment,
both with and without access logging enabled.

## Precondition

Before running the samples,install [service center](https://github.com/apache/servicecomb-service-center) and [kie](https://github.com/apache/servicecomb-kie). Or download [Lightweight Cloud Service Engine](https://support.huaweicloud.com/devg-cse/cse_devg_0036.html) which integrates both service center and kie for ease of use.
Before running the samples,install:

- [service center](https://github.com/apache/servicecomb-service-center)
- [kie](https://github.com/apache/servicecomb-kie)

Or download [Lightweight Cloud Service Engine](https://support.huaweicloud.com/devg-cse/cse_04_0046.html) which
integrates both service center and kie for ease of use.

# 使用ServiceComb开发微服务的示例项目
## 使用 ServiceComb 开发微服务的示例项目

这个项目使用java-chassis 2.0.x版本。可以切换分支,查看其他版本的例子。
这个项目使用 java-chassis 3.x.x 版本。可以切换分支,查看其他版本的例子。

## basic
该项目展示了Java Chassis开发的一个provider, 一个consumer和一个网关服务。

## porter_lightweight
该项目演示了一个包括网关、文件下载、认证鉴权等功能的简单应用系统,同时演示了ServiceComb推荐的先写接口声明,再写业务代码的软件工程实践。可以阅读[文章](https://servicecomb.apache.org/references/java-chassis/zh_CN/featured-topics/application-porter.html)了解项目的细节。这个例子的运行环境采用vert.x作为HTTP服务器,即 REST
over Vert.x transport。
该项目展示了 Java Chassis 开发的一个 provider, 一个 consumer 和一个网关服务。

## basic-tomcat

该项目展示了 Java Chassis 开发的一个 provider、一个 consumer 和一个网关服务。与 basic 项目不同的是,provider 和 consumer
被打包为 WAR 文件并部署在 tomcat 中。

## bmi

一个演示 BMI(身体质量指数)计算的微服务应用示例,包含一个计算器服务和具有网关功能的 Web 界面服务。该示例展示了如何在实际场景中构建和连接微服务。

## java-chassis-deployment-samples

一组部署示例,演示如何在外部 Web 容器中部署 java-chassis 应用,包括 Spring Boot 和传统的 WAR 部署方式。

## porter_springboot
该项目演示了一个包括网关、文件下载、认证鉴权等功能的简单应用系统,同时演示了ServiceComb推荐的先写接口声明,再写业务代码的软件工程实践。可以阅读[文章](https://servicecomb.apache.org/references/java-chassis/zh_CN/featured-topics/application-porter.html)了解项目的细节。这个例子的运行环境采用Spring Boot及其Embeded Tomcat,即
REST over Servlet。
## java-chassis-interoprability

展示 Spring Cloud 和 Java Chassis 框架之间的互操作性,特点是使用 Spring Cloud 网关通过 ServiceComb 和 Nacos
服务注册中心实现跨框架服务调用。

## porter

该项目演示了一个包括网关、文件下载、认证鉴权等功能的简单应用系统,同时演示了 ServiceComb
推荐的先写接口声明,再写业务代码的软件工程实践。可以阅读[文章](https://servicecomb.apache.org/references/java-chassis/zh_CN/featured-topics/application-porter.html)
了解项目的细节。
这个例子的运行环境采用 `vert.x` 作为 HTTP 服务器,即 `REST over Vert.x transport`。

## java-chassis-samples
java-chassis 各个模块功能的例子。每个子项目包含了10分钟可以学习完成的简单示例。

java-chassis 各个模块功能的例子。每个子项目包含了 10 分钟可以学习完成的简单示例。

## java-chassis-integration-tests
java-chassis 的集成测试用例。

java-chassis 的集成测试用例。

## java-chassis-benchmark

性能基准测试数据,比较了三个 RESTful 框架(`Dubbo 3.2.11`、`Spring Cloud 2022.0.x` 和 `ServiceComb Java-Chassis
3.0.1`)在不同测试条件下的表现:包括不同数据负载(1/100/1000)、等待时间(0/10/100ms)、10 个线程和 1000
次执行。包含了之前测试(2023-12-5、2023-11-16)的历史数据,涵盖了不同版本和 JDK 8 环境下启用和禁用访问日志的对比。

## 前提条件

运行这些例子之前,需要先安装[注册中心](https://github.com/apache/servicecomb-service-center) 和[配置中心](https://github.com/apache/servicecomb-kie) 。华为云提供一个出色的[本地轻量化微服务引擎](https://support.huaweicloud.com/devg-cse/cse_devg_0036.html) ,可以直接下载安装使用。
运行这些例子之前,需要先安装:

- [注册中心](https://github.com/apache/servicecomb-service-center)
- [配置中心](https://github.com/apache/servicecomb-kie)

> 华为云提供一个出色的[本地轻量化微服务引擎](https://support.huaweicloud.com/devg-cse/cse_04_0046.html) ,可以直接下载安装使用。
2 changes: 1 addition & 1 deletion ServiceComb-SpringMVC/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8u181-jdk-alpine
FROM eclipse-temurin:17-jdk-alpine

WORKDIR /home/apps/

Expand Down
83 changes: 68 additions & 15 deletions ServiceComb-SpringMVC/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,93 @@
# Java CSE Spring MVC microservice

| Language | Framework | Platform
| -------- | -------- |--------|
| Java | CSE Spring MVC | ServiceStage Container, CCE Cluster|
## Description

| Language | Framework | Platform |
| -------- | -------------- | ----------------------------------- |
| Java | CSE Spring MVC | ServiceStage Container, CCE Cluster |

This sample code helps get you started with a simple Java CSE microservice
deployed by ServiceStage Container App to a CCE Cluster.

This sample includes:

* README.md
* LICENSE
* Dockerfile
* pom.xml - this file is the Maven Project Object Model for the microservice
* src/main - this directory contains your Java service source files
* src/test - this directory contains your Java service unit test files
- `README.md`
- `LICENSE`
- `Dockerfile`
- `pom.xml` - this file is the Maven Project Object Model for the microservice
- `src/main` - this directory contains your Java service source files
- `src/test` - this directory contains your Java service unit test files

## Precondition
see [Precondition](../README.md)

see [Precondition](../README.md)

## Getting Started

Clone your code repository and start developing your application on IDE of your choice

1. Install maven. See https://maven.apache.org/install.html for details.
1. Install maven. See https://maven.apache.org/install.html for details.

2. Download local-service-center from http://servicecomb.incubator.apache.org/release/. Read README.md to start local-service-center.
2. Download `local-service-center` from http://servicecomb.incubator.apache.org/release/.
Read `README.md` to start`local-service-center`.
> Or download `Local-CSE` from [Local Lightweight Microservice Engine](https://support.huaweicloud.com/devg-cse/cse_04_0046.html).

3. Update the service registry address in microservice.yaml according to the README.md in local-service-center.
3. Update the service registry address in `microservice.yaml` according to the `README.md` in `local-service-center`.

4. Build the application.

$ mvn -f pom.xml package
```bash
mvn -f pom.xml package
```

5. Run the application in IDE or execute the jar.

6. Open http://127.0.0.1:8080/rest/helloworld?name=hellworld in a web browser to view your application.

if you want to deploy the sample code on servicestage, View your CI/CD pipeline and service stack on ServiceStage and customize it as per your needs
if you want to deploy the sample code on servicestage, View your CI/CD pipeline and service stack on ServiceStage and
customize it as per your needs

## 项目说明

| 语言 | 框架 | 平台 |
| ---- | -------------- | --------------------------- |
| Java | CSE Spring MVC | ServiceStage 容器, CCE 集群 |

本示例代码帮助您开始使用一个简单的 Java CSE 微服务,该服务通过 ServiceStage 容器应用部署到 CCE 集群。

本示例包含:

- `README.md`
- `LICENSE`
- `Dockerfile`
- `pom.xml` - 这个文件是微服务的 Maven 项目对象模型
- `src/main` - 这个目录包含您的 Java 服务源文件
- `src/test` - 这个目录包含您的 Java 服务单元测试文件

## 前置条件

参见[前置条件](../README.md)

## 入门指南

克隆您的代码仓库,并在您选择的 IDE 上开始开发应用

1. 安装 maven。详情请参见 https://maven.apache.org/install.html。

2. 从 http://servicecomb.incubator.apache.org/release/ 下载 `local-service-center`。
阅读 `README.md` 来启动 `local-service-center`。
> 或从[本地轻量化微服务引擎](https://support.huaweicloud.com/devg-cse/cse_04_0046.html)下载 `Local-CSE`。

3. 根据 `local-service-center` 中的 `README.md` 更新 `microservice.yaml` 中的服务注册地址。

4. 构建应用。

```bash
mvn -f pom.xml package
```

5. 在 IDE 中运行应用或执行 jar 包。

6. 在网络浏览器中打开 http://127.0.0.1:8080/rest/helloworld?name=hellworld 来查看您的应用。

如果您想在 servicestage 上部署示例代码,请查看您在 ServiceStage 上的 CI/CD 流水线和服务堆栈,并根据需要进行自定义。
29 changes: 17 additions & 12 deletions ServiceComb-SpringMVC/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
<name>servicecomb</name>
<url>http://maven.apache.org</url>
<properties>
<servicecomb.version>3.3.0</servicecomb.version>
<junit.version>4.13.1</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<demo.main>com.huawei.servicecomb.ServicecombspringmvcApplication</demo.main>
</properties>

Expand All @@ -39,7 +41,7 @@
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>java-chassis-dependencies</artifactId>
<version>2.6.0</version>
<version>${servicecomb.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -57,21 +59,24 @@
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>servicestage-environment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-service-center</artifactId>
<artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!--log4j2-->
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
</dependencies>

Expand All @@ -81,7 +86,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.huawei.servicecomb.ServicecombspringmvcApplication</mainClass>
<mainClass>${demo.main}</mainClass>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package com.huawei.servicecomb;

import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableServiceComb
public class ServicecombspringmvcApplication {
public static void main(String[] args) {
SpringApplication.run(ServicecombspringmvcApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
package com.huawei.servicecomb.controller;


import javax.ws.rs.core.MediaType;
import jakarta.annotation.Generated;
import jakarta.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.apache.servicecomb.provider.rest.common.RestSchema;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.CseSpringDemoCodegen", date = "2019-08-02T08:06:28.094Z")
@Generated(value = "io.swagger.codegen.languages.CseSpringDemoCodegen", date = "2019-08-02T08:06:28.094Z")

@RestSchema(schemaId = "servicecombspringmvc")
@RequestMapping(path = "/rest", produces = MediaType.APPLICATION_JSON)
Expand Down
28 changes: 0 additions & 28 deletions ServiceComb-SpringMVC/src/main/resources/log4j.properties

This file was deleted.

Loading