├── gs-rest-service ├── initial │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── hello │ │ │ └── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── build.gradle │ ├── pom.xml │ └── gradlew.bat ├── LICENSE.writing.txt ├── CONTRIBUTING.adoc ├── complete │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── manifest.yml │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.yml │ │ │ └── java │ │ │ │ └── hello │ │ │ │ ├── Application.java │ │ │ │ ├── Greeting.java │ │ │ │ └── GreetingController.java │ │ └── test │ │ │ └── java │ │ │ └── hello │ │ │ └── GreetingControllerTests.java │ ├── out │ │ └── production │ │ │ └── resources │ │ │ └── microservice.yaml │ ├── build.gradle │ ├── gradlew.bat │ └── pom.xml ├── .gitignore ├── .travis.yml ├── test │ └── run.sh ├── LICENSE.code.txt └── run-on-pws.json ├── spring-cloud-config-server-orginal ├── .mvn │ ├── jvm.config │ └── wrapper │ │ └── maven-wrapper.properties ├── docker-compose.yml ├── src │ ├── main │ │ ├── resources │ │ │ ├── keystore.jks │ │ │ ├── bootstrap.yml │ │ │ └── application.yml │ │ ├── docker │ │ │ └── Dockerfile │ │ └── java │ │ │ └── demo │ │ │ └── ConfigServerApplication.java │ └── test │ │ └── java │ │ └── demo │ │ └── ApplicationTests.java ├── .gitignore ├── .travis.yml └── README.md ├── gs-client-side-load-balancing ├── LICENSE.writing.txt ├── complete │ ├── settings.gradle │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── user │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ ├── src │ │ │ ├── main │ │ │ │ ├── resources │ │ │ │ │ └── application.yml │ │ │ │ └── java │ │ │ │ │ └── hello │ │ │ │ │ ├── SayHelloConfiguration.java │ │ │ │ │ └── UserApplication.java │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── hello │ │ │ │ └── UserApplicationTests.java │ │ ├── build.gradle │ │ ├── gradlew.bat │ │ └── pom.xml │ ├── say-hello │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ ├── src │ │ │ ├── main │ │ │ │ ├── resources │ │ │ │ │ └── application.yml │ │ │ │ └── java │ │ │ │ │ └── hello │ │ │ │ │ └── SayHelloApplication.java │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── hello │ │ │ │ └── SayHelloApplicationTests.java │ │ ├── build.gradle │ │ ├── gradlew.bat │ │ └── pom.xml │ ├── pom.xml │ └── gradlew.bat ├── initial │ ├── settings.gradle │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── say-hello │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ ├── build.gradle │ │ ├── pom.xml │ │ └── gradlew.bat │ ├── user │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ ├── build.gradle │ │ ├── pom.xml │ │ └── gradlew.bat │ ├── pom.xml │ └── gradlew.bat ├── CONTRIBUTING.adoc ├── .gitignore ├── test │ └── run.sh ├── LICENSE.code.txt └── .travis.yml ├── spring-boot-web ├── using-cse-in-spring-boot-001.png ├── using-cse-in-spring-boot-002.png ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── website │ │ │ ├── Application.java │ │ │ └── HelloService.java │ │ └── resources │ │ └── microservice.yaml └── pom.xml ├── spring-cloud-with-eureka-demo ├── provider │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── bootstrap.properties │ │ │ └── java │ │ │ └── hello │ │ │ └── ProviderApplication.java │ └── pom.xml ├── consumer │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── bootstrap.properties │ │ │ └── java │ │ │ └── hello │ │ │ ├── ProviderService.java │ │ │ ├── ServiceInstanceImpl.java │ │ │ └── ConsumerApplication.java │ └── pom.xml └── registry │ ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── hello │ │ └── EurekaServiceApplication.java │ └── pom.xml ├── gs-rest-service-with-servicecomb └── complete │ ├── src │ ├── main │ │ ├── java │ │ │ └── hello │ │ │ │ ├── IGreetingController.java │ │ │ │ ├── Greeting.java │ │ │ │ ├── GreetingController.java │ │ │ │ └── Application.java │ │ └── resources │ │ │ └── microservice.yaml │ └── test │ │ └── java │ │ └── hello │ │ └── GreetingControllerTests.java │ └── pom.xml ├── springcloud-sample-2-cse ├── springcloud-consumer │ ├── Dockerfile │ ├── start.sh │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── consumer │ │ │ │ ├── ClientMain.java │ │ │ │ ├── Hello.java │ │ │ │ └── HelloService.java │ │ │ └── resources │ │ │ └── application.yml │ ├── pom.xml │ └── README.md ├── springcloud-provider │ ├── Dockerfile │ ├── start.sh │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── provider │ │ │ │ ├── ServerMain.java │ │ │ │ ├── Hello.java │ │ │ │ └── HelloService.java │ │ │ └── resources │ │ │ └── application.yml │ ├── pom.xml │ └── README.md ├── README.md └── pom.xml ├── dubbo-migration ├── dubbo-demo-servicecomb │ ├── dubbo-demo-consumer │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── microservice.yaml │ │ │ │ ├── config │ │ │ │ │ └── log4j.properties │ │ │ │ └── META-INF │ │ │ │ │ └── spring │ │ │ │ │ └── demo.bean.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── alibaba │ │ │ │ │ └── dubbo │ │ │ │ │ └── demo │ │ │ │ │ └── consumer │ │ │ │ │ └── Consumer.java │ │ │ │ └── assembly │ │ │ │ ├── conf │ │ │ │ └── dubbo.properties │ │ │ │ └── assembly.xml │ │ └── pom.xml │ ├── dubbo-demo-provider │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── microservice.yaml │ │ │ │ ├── config │ │ │ │ │ └── log4j.properties │ │ │ │ └── META-INF │ │ │ │ │ └── spring │ │ │ │ │ └── demo.bean.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── alibaba │ │ │ │ │ └── dubbo │ │ │ │ │ └── demo │ │ │ │ │ └── provider │ │ │ │ │ ├── Provider.java │ │ │ │ │ └── DemoServiceImpl.java │ │ │ │ └── assembly │ │ │ │ ├── conf │ │ │ │ └── dubbo.properties │ │ │ │ └── assembly.xml │ │ └── pom.xml │ ├── dubbo-demo-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── alibaba │ │ │ │ └── dubbo │ │ │ │ └── demo │ │ │ │ └── DemoService.java │ │ └── pom.xml │ └── pom.xml ├── dubbo-demo │ ├── dubbo-demo-consumer │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── log4j.properties │ │ │ │ └── META-INF │ │ │ │ │ └── spring │ │ │ │ │ └── dubbo-demo-consumer.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── alibaba │ │ │ │ │ └── dubbo │ │ │ │ │ └── demo │ │ │ │ │ └── consumer │ │ │ │ │ └── Consumer.java │ │ │ │ └── assembly │ │ │ │ ├── conf │ │ │ │ └── dubbo.properties │ │ │ │ └── assembly.xml │ │ └── pom.xml │ ├── dubbo-demo-provider │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── log4j.properties │ │ │ │ └── META-INF │ │ │ │ │ └── spring │ │ │ │ │ └── dubbo-demo-provider.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── alibaba │ │ │ │ │ └── dubbo │ │ │ │ │ └── demo │ │ │ │ │ └── provider │ │ │ │ │ ├── Provider.java │ │ │ │ │ └── DemoServiceImpl.java │ │ │ │ └── assembly │ │ │ │ ├── conf │ │ │ │ └── dubbo.properties │ │ │ │ └── assembly.xml │ │ └── pom.xml │ ├── dubbo-demo-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── alibaba │ │ │ │ └── dubbo │ │ │ │ └── demo │ │ │ │ └── DemoService.java │ │ └── pom.xml │ └── pom.xml └── README.md ├── springcloud-sample ├── eureka-server │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── io │ │ │ └── eureka │ │ │ └── EurekaServer.java │ └── pom.xml ├── springcloud-provider │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── io │ │ │ └── provider │ │ │ ├── ServerMain.java │ │ │ ├── Hello.java │ │ │ └── HelloService.java │ └── pom.xml ├── springcloud-consumer │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── io │ │ │ └── consumer │ │ │ ├── ClientMain.java │ │ │ ├── Hello.java │ │ │ └── HelloService.java │ └── pom.xml ├── README.md └── pom.xml ├── README.md ├── spring-boot-simple ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── website │ │ │ ├── WebsiteMain.java │ │ │ └── HelloService.java │ │ └── resources │ │ └── microservice.yaml └── pom.xml ├── spring-boot-tomcat-war-deploy ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── website │ │ │ ├── HelloService.java │ │ │ └── WebsiteMain.java │ │ └── resources │ │ └── microservice.yaml ├── README.md └── pom.xml └── .gitignore /gs-rest-service/initial/src/main/java/hello/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gs-rest-service/LICENSE.writing.txt: -------------------------------------------------------------------------------- 1 | Except where otherwise noted, this work is licensed under http://creativecommons.org/licenses/by-nd/3.0/ 2 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom -------------------------------------------------------------------------------- /gs-client-side-load-balancing/LICENSE.writing.txt: -------------------------------------------------------------------------------- 1 | Except where otherwise noted, this work is licensed under http://creativecommons.org/licenses/by-nd/3.0/ 2 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'gs-client-side-load-balancing' 2 | 3 | include 'say-hello' 4 | include 'user' 5 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'gs-client-side-load-balancing' 2 | 3 | include 'say-hello' 4 | include 'user' 5 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/docker-compose.yml: -------------------------------------------------------------------------------- 1 | rabbitmq: 2 | image: rabbitmq:3-management 3 | ports: 4 | - "5672:5672" 5 | - "15672:15672" 6 | -------------------------------------------------------------------------------- /gs-rest-service/CONTRIBUTING.adoc: -------------------------------------------------------------------------------- 1 | If you have not previously done so, please fill out and 2 | submit the https://cla.pivotal.io/sign/spring[Contributor License Agreement]. -------------------------------------------------------------------------------- /gs-rest-service/complete/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /gs-rest-service/initial/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /spring-boot-web/using-cse-in-spring-boot-001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huawei-microservice-demo/SpringCloudIntegration/HEAD/spring-boot-web/using-cse-in-spring-boot-001.png -------------------------------------------------------------------------------- /spring-boot-web/using-cse-in-spring-boot-002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huawei-microservice-demo/SpringCloudIntegration/HEAD/spring-boot-web/using-cse-in-spring-boot-002.png -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip -------------------------------------------------------------------------------- /gs-client-side-load-balancing/CONTRIBUTING.adoc: -------------------------------------------------------------------------------- 1 | If you have not previously done so, please fill out and 2 | submit the https://cla.pivotal.io/sign/spring[Contributor License Agreement]. -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/provider/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=9990 3 | eureka.client.serviceUrl.defaultZone=http://localhost:8762/eureka/ -------------------------------------------------------------------------------- /gs-rest-service-with-servicecomb/complete/src/main/java/hello/IGreetingController.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public interface IGreetingController { 4 | public Greeting greeting(String name); 5 | } 6 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/consumer/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=consumer 2 | server.port=9991 3 | eureka.client.serviceUrl.defaultZone=http://localhost:8762/eureka/ 4 | 5 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/src/main/resources/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huawei-microservice-demo/SpringCloudIntegration/HEAD/spring-cloud-config-server-orginal/src/main/resources/keystore.jks -------------------------------------------------------------------------------- /gs-rest-service/complete/manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: gs-rest-service 4 | memory: 256M 5 | instances: 1 6 | host: rest-service 7 | domain: guides.spring.io 8 | path: build/libs/gs-rest-service-0.1.0.jar 9 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8u111-jre-alpine 2 | 3 | WORKDIR /home/apps/ 4 | ADD target/springcloud-consumer-0.0.1-SNAPSHOT.jar . 5 | ADD start.sh . 6 | 7 | ENTRYPOINT ["sh", "/home/apps/start.sh"] -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8u111-jre-alpine 2 | 3 | WORKDIR /home/apps/ 4 | ADD target/springcloud-provider-0.0.1-SNAPSHOT.jar . 5 | ADD start.sh . 6 | 7 | ENTRYPOINT ["sh", "/home/apps/start.sh"] -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | #* 3 | *# 4 | .#* 5 | .classpath 6 | .project 7 | .settings 8 | .springBeans 9 | .gradle 10 | build 11 | bin 12 | /target/ 13 | git.properties 14 | .idea 15 | *.iml 16 | .factorypath 17 | -------------------------------------------------------------------------------- /gs-rest-service/.gitignore: -------------------------------------------------------------------------------- 1 | *.sw? 2 | .#* 3 | *# 4 | *~ 5 | .classpath 6 | .project 7 | .settings 8 | bin 9 | build 10 | target 11 | dependency-reduced-pom.xml 12 | *.sublime-* 13 | /scratch 14 | .gradle 15 | README.html 16 | *.iml 17 | .idea 18 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # CMDVAR="-Djava.security.egd=file:/dev/./urandom","java -agentlib:jdwp=transport=dt_socket,address=0:8000,server=y,suspend=n -jar" 4 | java $CMDVAR -jar ./springcloud-consumer-0.0.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # CMDVAR="-Djava.security.egd=file:/dev/./urandom","java -agentlib:jdwp=transport=dt_socket,address=0:8000,server=y,suspend=n -jar" 4 | java $CMDVAR -jar ./springcloud-provider-0.0.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:7 2 | ADD configserver-0.0.1-SNAPSHOT.jar app.jar 3 | VOLUME /tmp 4 | VOLUME /target 5 | RUN bash -c 'touch /app.jar' 6 | EXPOSE 8888 7 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/registry/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8762 2 | 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false 5 | 6 | logging.level.com.netflix.eureka=OFF 7 | logging.level.com.netflix.discovery=OFF 8 | 9 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | servers: 3 | - redis-server 4 | before_install: git clone https://github.com/dsyer/spring-security-rsa tmp && (cd tmp && mvn install -DskipTests=true) 5 | script: mvn package -nsu -Dmaven.test.redirectTestOutputToFile=true 6 | -------------------------------------------------------------------------------- /gs-rest-service/complete/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:08:10 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /gs-rest-service/initial/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:08:14 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-consumer/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | APPLICATION_ID: dubbo_servicecomb 2 | service_description: 3 | name: consumer 4 | version: 0.0.1 5 | cse: 6 | service: 7 | registry: 8 | address: http://127.0.0.1:30100 9 | rest: 10 | address: 0.0.0.0:8084 -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | APPLICATION_ID: dubbo_servicecomb 2 | service_description: 3 | name: provider 4 | version: 0.0.1 5 | cse: 6 | service: 7 | registry: 8 | address: http://127.0.0.1:30100 9 | rest: 10 | address: 0.0.0.0:8082 -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 08 16:13:04 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip 7 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 11 10:17:09 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip 7 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: configserver 4 | encrypt: 5 | failOnError: false 6 | keyStore: 7 | location: classpath:keystore.jks 8 | password: ${KEYSTORE_PASSWORD:foobar} # don't use a default in production 9 | alias: test 10 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:05:41 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/say-hello/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:05:45 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/user/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:05:48 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip1fff 7 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/say-hello/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:05:38 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /springcloud-sample/eureka-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka-server 2 | server.port=7071 3 | eureka.instance.hostname=localhost 4 | 5 | eureka.client.register-with-eureka=false 6 | eureka.client.fetch-registry=false 7 | eureka.client.serviceUrl.defaultZone=http://0.0.0.0:${server.port}/eureka/ 8 | -------------------------------------------------------------------------------- /gs-rest-service/complete/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9090 3 | spring: 4 | application: 5 | name: spring-cloud-demo 6 | ### CSE configurations ######### 7 | cse: 8 | credentials: 9 | accessKey: your access key 10 | secretKey: your secret key 11 | akskCustomCipher: default 12 | ### END OF CSE configurations ######### -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/say-hello/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: say-hello 4 | 5 | server: 6 | port: 8090 7 | ### CSE configurations ######### 8 | cse: 9 | credentials: 10 | accessKey: your access key 11 | secretKey: your secret key 12 | akskCustomCipher: default 13 | ### END OF CSE configurations ######### -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-consumer/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ###set log levels### 2 | log4j.rootLogger=info, stdout 3 | ###输出到控制台### 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.Target=System.out 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-provider/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ###set log levels### 2 | log4j.rootLogger=info, stdout 3 | ###输出到控制台### 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.Target=System.out 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n -------------------------------------------------------------------------------- /gs-rest-service/complete/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-consumer/src/main/resources/config/log4j.properties: -------------------------------------------------------------------------------- 1 | ###set log levels### 2 | log4j.rootLogger=info, stdout 3 | ###输出到控制台### 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.Target=System.out 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/src/main/resources/config/log4j.properties: -------------------------------------------------------------------------------- 1 | ###set log levels### 2 | log4j.rootLogger=info, stdout 3 | ###输出到控制台### 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.Target=System.out 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n -------------------------------------------------------------------------------- /gs-client-side-load-balancing/.gitignore: -------------------------------------------------------------------------------- 1 | # Operating System Files 2 | 3 | *.DS_Store 4 | Thumbs.db 5 | *.sw? 6 | .#* 7 | *# 8 | *~ 9 | *.sublime-* 10 | 11 | # Build Artifacts 12 | 13 | .gradle/ 14 | build/ 15 | target/ 16 | bin/ 17 | dependency-reduced-pom.xml 18 | 19 | # Eclipse Project Files 20 | 21 | .classpath 22 | .project 23 | .settings/ 24 | 25 | # IntelliJ IDEA Files 26 | 27 | *.iml 28 | *.ipr 29 | *.iws 30 | *.idea 31 | 32 | README.html 33 | -------------------------------------------------------------------------------- /gs-rest-service/complete/src/main/java/hello/Greeting.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public class Greeting { 4 | 5 | private final long id; 6 | private final String content; 7 | 8 | public Greeting(long id, String content) { 9 | this.id = id; 10 | this.content = content; 11 | } 12 | 13 | public long getId() { 14 | return id; 15 | } 16 | 17 | public String getContent() { 18 | return content; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-provider/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: helloprovider 4 | 5 | server: 6 | port: 7111 7 | 8 | eureka: 9 | client: 10 | serviceUrl: 11 | defaultZone: http://localhost:7071/eureka/ 12 | instance: 13 | leaseRenewalIntervalInSeconds: 10 14 | metadataMap: 15 | instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}} -------------------------------------------------------------------------------- /gs-rest-service-with-servicecomb/complete/src/main/java/hello/Greeting.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public class Greeting { 4 | 5 | private long id; 6 | private String content; 7 | public Greeting() { 8 | 9 | } 10 | public Greeting(long id, String content) { 11 | this.id = id; 12 | this.content = content; 13 | } 14 | 15 | public long getId() { 16 | return id; 17 | } 18 | 19 | public String getContent() { 20 | return content; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gs-rest-service/complete/out/production/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | APPLICATION_ID: spring-cloud-app 3 | service_description: 4 | name: spring-cloud-demo 5 | version: 0.0.1 6 | cse: 7 | service: 8 | registry: 9 | address: https://cse.cn-north-1.myhwclouds.com:443 10 | instance: 11 | watch: false 12 | rest: 13 | address: 0.0.0.0:9090 14 | credentials: 15 | accessKey: your access key 16 | secretKey: your secret key 17 | akskCustomCipher: default -------------------------------------------------------------------------------- /springcloud-sample/springcloud-provider/src/main/java/io/provider/ServerMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class ServerMain { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ServerMain.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THIS IS UNMAINTAINED 2 | As Eureka is no longer MAINTAINED, we decide to develop a new solution https://github.com/huaweicloud/spring-cloud-huawei to bring more valuable feature for users of servicecomb and huawei cloud. 3 | 4 | Moving forward I would suggest you use spring cloud huawei for those reasons: 5 | 6 | - service mesh solution 7 | - high perfomance API gateway 8 | - route management, canary release 9 | - work both on cloud and on-premise platform(compatible with both huawei cloud and ServiceComb) 10 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/src/main/java/io/provider/ServerMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class ServerMain { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ServerMain.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: helloprovider 4 | 5 | server: 6 | port: 7111 7 | 8 | eureka: 9 | client: 10 | serviceUrl: 11 | defaultZone: http://localhost:7071/eureka/ 12 | instance: 13 | leaseRenewalIntervalInSeconds: 10 14 | metadataMap: 15 | instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}} 16 | cse: 17 | credentials: 18 | project: cn-north-1 -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/Provider.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.dubbo.demo.provider; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | /** 7 | * Created by ken.lj on 2017/7/31. 8 | */ 9 | public class Provider { 10 | 11 | public static void main(String[] args) throws Exception { 12 | Log4jUtils.init(); 13 | BeanUtils.init(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-simple/src/main/java/com/huawei/cse/porter/website/WebsiteMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.website; 2 | 3 | import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class WebsiteMain { 10 | public static void main(final String[] args) { 11 | SpringApplication.run(WebsiteMain.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/registry/src/main/java/hello/EurekaServiceApplication.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @EnableEurekaServer 8 | @SpringBootApplication 9 | public class EurekaServiceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaServiceApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd $(dirname $0) 3 | 4 | cd ../complete 5 | 6 | mvn clean package 7 | ret=$? 8 | if [ $ret -ne 0 ]; then 9 | exit $ret 10 | fi 11 | rm -rf target 12 | 13 | ./gradlew build 14 | ret=$? 15 | if [ $ret -ne 0 ]; then 16 | exit $ret 17 | fi 18 | rm -rf build 19 | 20 | cd ../initial 21 | 22 | mvn clean compile 23 | ret=$? 24 | if [ $ret -ne 0 ]; then 25 | exit $ret 26 | fi 27 | rm -rf target 28 | 29 | ./gradlew compileJava 30 | ret=$? 31 | if [ $ret -ne 0 ]; then 32 | exit $ret 33 | fi 34 | rm -rf build 35 | 36 | exit 37 | -------------------------------------------------------------------------------- /springcloud-sample/eureka-server/src/main/java/io/eureka/EurekaServer.java: -------------------------------------------------------------------------------- 1 | package io.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @EnableEurekaServer 8 | @SpringBootApplication 9 | public class EurekaServer { 10 | 11 | public static void main(String[] args) { 12 | // new SpringApplicationBuilder(EurekaServer.class).web(true).run(args); 13 | SpringApplication.run(EurekaServer.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-consumer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: helloconsumer 4 | server: 5 | port: 7211 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:7071/eureka/ 10 | instance: 11 | leaseRenewalIntervalInSeconds: 10 12 | metadataMap: 13 | instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}} 14 | endpoints: 15 | restart: 16 | enabled: true 17 | shutdown: 18 | enabled: true 19 | health: 20 | sensitive: false -------------------------------------------------------------------------------- /springcloud-sample/springcloud-consumer/src/main/java/io/consumer/ClientMain.java: -------------------------------------------------------------------------------- 1 | package io.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableFeignClients 11 | public class ClientMain { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ClientMain.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/src/main/java/io/consumer/ClientMain.java: -------------------------------------------------------------------------------- 1 | package io.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableFeignClients 11 | public class ClientMain { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ClientMain.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/Provider.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.dubbo.demo.provider; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | /** 6 | * Created by ken.lj on 2017/7/31. 7 | */ 8 | public class Provider { 9 | 10 | public static void main(String[] args) throws Exception { 11 | ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-provider.xml"}); 12 | context.start(); 13 | 14 | System.in.read(); // 按任意键退出 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /springcloud-sample/README.md: -------------------------------------------------------------------------------- 1 | ## SpringCloud业务代码零修改接入CSE 2 | 3 | 这里是一个原始Spring Cloud应用,请参考[Spring Cloud应用接入CSE](https://support.huaweicloud.com/bestpractice-cse/cse_03_0092.html)体验Spring Cloud应用如何经过少量的配置修改,快速接入CSE 4 | 5 | 修改后Demo请参考[springcloud-sample-2-cse](https://github.com/huawei-microservice-demo/SpringCloudIntegration/tree/master/springcloud-sample-2-cse) 6 | 7 | 访问[http://localhost:7111/hello/sayhi?name=springcloud](http://localhost:7111/hello/sayhi?name=springcloud),调用helloprovider服务/hello/sayhi接口 8 | 9 | 访问[http://localhost:7211/hello?name=springcloud](http://localhost:7211/hello?name=springcloud),调用helloconsumer服务/hello接口(消费helloprovider) -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-client-side-load-balancing 8 | 0.1.0 9 | pom 10 | 11 | 12 | say-hello 13 | user 14 | 15 | 16 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-client-side-load-balancing 8 | 0.1.0 9 | pom 10 | 11 | 12 | say-hello 13 | user 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-boot-simple/src/main/java/com/huawei/cse/porter/website/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.website; 2 | 3 | import org.apache.servicecomb.provider.rest.common.RestSchema; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @RestSchema(schemaId = "hello") 9 | @RequestMapping(path = "/") 10 | public class HelloService { 11 | @RequestMapping(path = "hello", method = RequestMethod.GET) 12 | public String sayHello(@RequestParam(name="name") String name) { 13 | return "Hello " + name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-tomcat-war-deploy/src/main/java/com/huawei/cse/porter/website/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.website; 2 | 3 | import org.apache.servicecomb.provider.rest.common.RestSchema; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @RestSchema(schemaId = "hello") 9 | @RequestMapping(path = "/") 10 | public class HelloService { 11 | @RequestMapping(path = "hello", method = RequestMethod.GET) 12 | public String sayHello(@RequestParam(name="name") String name) { 13 | return "Hello " + name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/huawei/cse/porter/website/Application.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.website; 2 | 3 | import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration; 7 | 8 | @SpringBootApplication(exclude=DispatcherServletAutoConfiguration.class) 9 | @EnableServiceComb 10 | public class Application { 11 | public static void main(final String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gs-rest-service-with-servicecomb/complete/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | APPLICATION_ID: spring-cloud-app 3 | service_description: 4 | name: spring-cloud-with-servicecomb-demo 5 | version: 0.0.1 6 | cse: 7 | service: 8 | registry: 9 | address: https://cse.cn-north-1.myhwclouds.com:443 10 | instance: 11 | watch: false 12 | config: 13 | client: 14 | serverUri: https://cse.cn-north-1.myhwclouds.com:443 15 | refreshMode: 1 16 | refresh_interval: 15000 17 | rest: 18 | address: 0.0.0.0:9999 19 | credentials: 20 | accessKey: Your access key in CSE 21 | secretKey: Your secret key in CSE 22 | akskCustomCipher: default 23 | 24 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: user 4 | 5 | server: 6 | port: 8888 7 | 8 | say-hello: 9 | ribbon: 10 | eureka: 11 | enabled: true 12 | # listOfServers: localhost:8090,localhost:9092,localhost:9999 13 | ServerListRefreshInterval: 15000 14 | eureka: 15 | client: 16 | serviceUrl: 17 | defaultZone: http://127.0.0.1:8761/eureka 18 | zuul: 19 | routes: 20 | api: 21 | serviceId: say-hello 22 | ### CSE configurations ######### 23 | cse: 24 | credentials: 25 | accessKey: your access key 26 | secretKey: your secret key 27 | akskCustomCipher: default 28 | ### END OF CSE configurations ######### -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/src/main/java/demo/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.config.server.EnableConfigServer; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Configuration 10 | @EnableAutoConfiguration 11 | @EnableDiscoveryClient 12 | @EnableConfigServer 13 | public class ConfigServerApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(ConfigServerApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /gs-rest-service/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: java 3 | jdk: 4 | - oraclejdk8 5 | script: 6 | - test/run.sh 7 | notifications: 8 | slack: 9 | secure: Q1BghE2l8ObVqw6ehUozBATpdwhTFRHg3zZPqeMf9alR5O+g7GT3JvYbZpapNygUbVWhi4l2zrN1Sp91Eqr8IbsGxYbKwN27if45VmvoXWwN0y0s2UKuCBfTJDvcXskbUn8wKdwR3LrH95ji+GYT5Gh5clC3G3q6HkeYffcTeX4= 10 | env: 11 | global: 12 | - secure: FT6/wRYEWG5K1b48W+HO2gtPXJ59Oed3igc6pBIJojPV9WYDymTRP8e/zc6sKeDHN4SXM35ls3sdXaTHKP0sX7rZMRHtDdgrmWMMNsOsk3UoerkLjrfkr3uLkY6oM4mgiS1kLov2MDeiUAudbSxP6qx75v/RFFOoymeyQlXuJiA= 13 | - secure: BW+8fUbrEIzlmoJUOrtbgNYJKh7Rp42exQOyC+7DWtGvDfJmDrE7unht/rjWEjsLKiB7gAG9ZFX4oMzMmJ/KQxic5qfW8ztcbRvDuFTo5iqF+mZKGxVstgKSZ/OrEOCLZ3Gmqa/7dcS2VnGy9KdWwDKlglm7pc5SavQzThvYhG8= 14 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/consumer/src/main/java/hello/ProviderService.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.cloud.client.ServiceInstance; 6 | import org.springframework.cloud.netflix.feign.FeignClient; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | 11 | @FeignClient(name = "provider") 12 | public interface ProviderService { 13 | @GetMapping("/service-instances/{applicationName}") 14 | public List serviceInstancesByApplicationName( 15 | @PathVariable(value = "applicationName") String applicationName); 16 | } 17 | -------------------------------------------------------------------------------- /gs-rest-service/initial/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE") 7 | } 8 | } 9 | 10 | apply plugin: 'java' 11 | apply plugin: 'eclipse' 12 | apply plugin: 'idea' 13 | apply plugin: 'org.springframework.boot' 14 | 15 | jar { 16 | baseName = 'gs-rest-service' 17 | version = '0.1.0' 18 | } 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | sourceCompatibility = 1.8 25 | targetCompatibility = 1.8 26 | 27 | dependencies { 28 | compile("org.springframework.boot:spring-boot-starter-web") 29 | testCompile('org.springframework.boot:spring-boot-starter-test') 30 | } 31 | 32 | -------------------------------------------------------------------------------- /gs-rest-service/test/run.sh: -------------------------------------------------------------------------------- 1 | cd $(dirname $0) 2 | cd ../initial 3 | 4 | mvn clean compile 5 | ret=$? 6 | if [ $ret -ne 0 ]; then 7 | exit $ret 8 | fi 9 | rm -rf target 10 | 11 | ./gradlew compileJava 12 | ret=$? 13 | if [ $ret -ne 0 ]; then 14 | exit $ret 15 | fi 16 | rm -rf build 17 | 18 | cd ../complete 19 | mvn clean package 20 | 21 | # if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; 22 | # then 23 | # curl https://raw.githubusercontent.com/timkay/aws/master/aws -o aws 24 | # chmod u+x aws 25 | # ./aws put --progress "x-amz-acl: public-read" springio-guides/gs-rest-service-0.1.0.jar target/gs-rest-service-0.1.0.jar 26 | # fi 27 | 28 | rm -rf target 29 | 30 | ./gradlew build 31 | ret=$? 32 | if [ $ret -ne 0 ]; then 33 | exit $ret 34 | fi 35 | 36 | rm -rf build 37 | exit 38 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: helloconsumer 4 | server: 5 | port: 7211 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:7071/eureka/ 10 | instance: 11 | leaseRenewalIntervalInSeconds: 10 12 | metadataMap: 13 | instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}} 14 | endpoints: 15 | restart: 16 | enabled: true 17 | shutdown: 18 | enabled: true 19 | health: 20 | sensitive: false 21 | helloprovider: 22 | ribbon: 23 | NIWSServerListClassName: org.apache.servicecomb.springboot.starter.discovery.ServiceCombServerList 24 | cse: 25 | credentials: 26 | project: cn-north-1 -------------------------------------------------------------------------------- /gs-rest-service/LICENSE.code.txt: -------------------------------------------------------------------------------- 1 | All code in this repository is: 2 | ======================================================================= 3 | Copyright (c) 2013 GoPivotal, Inc. All Rights Reserved 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | -------------------------------------------------------------------------------- /gs-rest-service/complete/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE") 7 | } 8 | } 9 | 10 | apply plugin: 'java' 11 | apply plugin: 'eclipse' 12 | apply plugin: 'idea' 13 | apply plugin: 'org.springframework.boot' 14 | 15 | jar { 16 | baseName = 'gs-rest-service' 17 | version = '0.1.0' 18 | } 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | sourceCompatibility = 1.8 25 | targetCompatibility = 1.8 26 | 27 | dependencies { 28 | compile("org.springframework.boot:spring-boot-starter-web") 29 | testCompile('org.springframework.boot:spring-boot-starter-test') 30 | testCompile('com.jayway.jsonpath:json-path') 31 | } 32 | 33 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/LICENSE.code.txt: -------------------------------------------------------------------------------- 1 | All code in this repository is: 2 | ======================================================================= 3 | Copyright (c) 2013 GoPivotal, Inc. All Rights Reserved 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | script: 5 | - test/run.sh 6 | notifications: 7 | slack: 8 | secure: Gxk8telmCqynsHzvMJNT5s12vBUPotfQBlOjgHj6Brsyrxz0WpsZgcnGhG5sqve1cyr4PrKv0coWR2uqc2PIOU2ZhtYW5sHzLjd+fyPv334uUqJRvY0+6eewIfpsx2CNUHl43c3W+ASik1cysysB5H1Olo8TbjLhINA4o7/mysOdYx0S2LU7HPltRBsA84YCScNawGHB7HpyUKaK/9yQjC0qejWKVTwvTxXpGFQXqxPCYSgZ2Ey0CqfGCxGu4G5B1pGLJA3MnSmuz9twa4O6PkqDhvEQzIcz7Bm4mrB32LB79Ffo5JRwhbu5r0tpV5bdVxxi0rajoswUPVu5vYQfuz74zdO/Jm7mziYCj1a12J/RzIWlfGAKnNt5T5YLlMZWO+Q4Ff5TZQWrfFqA4I1VVJoMGavc9Yj0aAyfMSRX5nwLYv2SOpKj9emdyvQiVcB3sBbDhcFGvH5JKTq3Hmrt/UW94ceCTIGpG7vrCuCCs3mf7+AUO7n+7OOcz780l8MUefHstEKdH/1i2jutrmy3rjzl8c/DBfpcNvjc+LxP/b8iAQP2u1n7r+PYF298w2a++5GUf7zF2Wdb8/RHU2JnFblnCed6oMdDcd46CkCCwvFVlWUTgKtSmTaZjHfn38L2gyL3fIrxz8calMI8n3VD8S4xZ19/TqxBXe1+zoNAgWA= 9 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/README.md: -------------------------------------------------------------------------------- 1 | ## SpringCloud业务代码零修改接入CSE 2 | 3 | 这里是一个原始Spring Cloud应用经过少量的配置修改后,快速接入CSE的Demo 4 | 5 | 快速接入指南:[Spring Cloud应用接入CSE](https://support.huaweicloud.com/bestpractice-cse/cse_03_0092.html) 6 | 7 | 原始Spring Cloud:[springcloud-sample](https://github.com/huawei-microservice-demo/SpringCloudIntegration/tree/master/springcloud-sample) 8 | 9 | 说明:本地运行此Demo请参考快速接入指南,在application.yml中增加认证信息,认证信息包含AS/SK,可以从公有云帐号的[我的凭证](https://support.huaweicloud.com/usermanual-iam/zh-cn_topic_0079477318.html)获取,云上部署无需提供认证信息,部署平台将自动认证。 10 | 11 | 访问[http://localhost:7111/hello/sayhi?name=springcloud](http://localhost:7111/hello/sayhi?name=springcloud),调用helloprovider服务/hello/sayhi接口 12 | 13 | 访问[http://localhost:7211/hello?name=springcloud](http://localhost:7211/hello?name=springcloud),调用helloconsumer服务/hello接口(消费helloprovider) 14 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-consumer/src/main/java/com/alibaba/dubbo/demo/consumer/Consumer.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.dubbo.demo.consumer; 2 | 3 | import com.alibaba.dubbo.demo.DemoService; 4 | 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | /** 8 | * Created by ken.lj on 2017/7/31. 9 | */ 10 | public class Consumer { 11 | 12 | public static void main(String[] args) { 13 | ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-consumer.xml"}); 14 | context.start(); 15 | 16 | DemoService demoService = (DemoService) context.getBean("demoService"); // 获取远程服务代理 17 | String hello = demoService.sayHello("world"); // 执行远程方法 18 | 19 | System.out.println(hello); // 显示调用结果 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-consumer/src/main/resources/META-INF/spring/demo.bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/src/main/resources/META-INF/spring/demo.bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-api/src/main/java/com/alibaba/dubbo/demo/DemoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2011 Alibaba Group. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.dubbo.demo; 17 | 18 | public interface DemoService { 19 | 20 | String sayHello(String name); 21 | 22 | } -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-api/src/main/java/com/alibaba/dubbo/demo/DemoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2011 Alibaba Group. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.dubbo.demo; 17 | 18 | public interface DemoService { 19 | 20 | String sayHello(String name); 21 | 22 | } -------------------------------------------------------------------------------- /spring-boot-tomcat-war-deploy/src/main/java/com/huawei/cse/porter/website/WebsiteMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.website; 2 | 3 | import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | import org.springframework.boot.context.web.SpringBootServletInitializer; 8 | 9 | @SpringBootApplication 10 | @EnableServiceComb 11 | public class WebsiteMain extends SpringBootServletInitializer { 12 | 13 | @Override 14 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 15 | return application.sources(WebsiteMain.class); 16 | } 17 | 18 | public static void main(final String[] args) { 19 | SpringApplication.run(WebsiteMain.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /springcloud-sample/eureka-server/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample 7 | 0.0.1-SNAPSHOT 8 | 9 | eureka-server 10 | 11 | 12 | 13 | org.springframework.cloud 14 | spring-cloud-starter-eureka-server 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-maven-plugin 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/huawei/cse/porter/website/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.website; 2 | 3 | import org.apache.servicecomb.provider.pojo.RpcReference; 4 | import org.apache.servicecomb.provider.rest.common.RestSchema; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | @RestSchema(schemaId = "hello") 10 | @RequestMapping(path = "/") 11 | public class HelloService { 12 | @RpcReference(microserviceName = "spring-boot-simple", schemaId = "hello") 13 | Hello hello; 14 | 15 | @RequestMapping(path = "hello", method = RequestMethod.GET) 16 | public String sayHello(@RequestParam(name="name") String name) { 17 | if(name.equals("internal")){ 18 | return "Hello " + name; 19 | } 20 | return hello.sayHello("internal"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-consumer/src/main/java/com/alibaba/dubbo/demo/consumer/Consumer.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.dubbo.demo.consumer; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | import org.apache.servicecomb.provider.pojo.RpcReference; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.alibaba.dubbo.demo.DemoService; 9 | 10 | /** 11 | * Created by ken.lj on 2017/7/31. 12 | */ 13 | @Component 14 | public class Consumer { 15 | 16 | @RpcReference(microserviceName="provider", schemaId="providerSchema") 17 | private static DemoService demoService; 18 | 19 | public static void main(String[] args) throws Exception { 20 | Log4jUtils.init(); 21 | BeanUtils.init(); 22 | 23 | String hello = demoService.sayHello("world"); // 执行远程方法 24 | 25 | System.out.println(hello); // 显示调用结果 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | 4 | management: 5 | context-path: /admin 6 | 7 | logging: 8 | level: 9 | com.netflix.discovery: 'OFF' 10 | org.springframework.cloud: 'DEBUG' 11 | 12 | eureka: 13 | instance: 14 | leaseRenewalIntervalInSeconds: 10 15 | statusPageUrlPath: /admin/info 16 | healthCheckUrlPath: /admin/health 17 | 18 | spring: 19 | cloud: 20 | config: 21 | server: 22 | git: 23 | uri: https://github.com/spring-cloud-samples/config-repo 24 | basedir: target/config 25 | 26 | --- 27 | spring: 28 | profiles: cloud 29 | eureka: 30 | password: password 31 | instance: 32 | hostname: ${vcap.application.uris[0]} 33 | nonSecurePort: 80 34 | client: 35 | serviceUrl: 36 | defaultZone: ${vcap.services.${PREFIX:}eureka.credentials.uri:http://user:${eureka.password:}@${PREFIX:}eureka.${application.domain:cfapps.io}}/eureka/ 37 | 38 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-provider/src/main/java/io/provider/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package io.provider; 18 | 19 | public interface Hello { 20 | 21 | String sayHi(String name); 22 | } 23 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/say-hello/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.5.9.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'eclipse' 15 | apply plugin: 'org.springframework.boot' 16 | 17 | jar { 18 | baseName = 'say-hello' 19 | version = '0.0.1-SNAPSHOT' 20 | } 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | repositories { 25 | mavenCentral() 26 | } 27 | 28 | 29 | dependencies { 30 | compile('org.springframework.boot:spring-boot-starter-web') 31 | testCompile('org.springframework.boot:spring-boot-starter-test') 32 | } 33 | 34 | 35 | eclipse { 36 | classpath { 37 | containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') 38 | containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/say-hello/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.5.9.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'eclipse' 15 | apply plugin: 'org.springframework.boot' 16 | 17 | jar { 18 | baseName = 'say-hello' 19 | version = '0.0.1-SNAPSHOT' 20 | } 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | repositories { 25 | mavenCentral() 26 | } 27 | 28 | 29 | dependencies { 30 | compile('org.springframework.boot:spring-boot-starter-web') 31 | testCompile('org.springframework.boot:spring-boot-starter-test') 32 | } 33 | 34 | 35 | eclipse { 36 | classpath { 37 | containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') 38 | containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /spring-boot-tomcat-war-deploy/README.md: -------------------------------------------------------------------------------- 1 | This project is created for checking the issue related to tomcat and servicecomb combination. 2 | 3 | # Steps to build 4 | 1. Befor build make sure the dependency is correct. Please download the cse dependency manually and add it. 5 | https://github.com/huawei-microservice-demo/huawei-microservice-demo 6 | or 7 | define the mirror like below in maven settings.xml 8 | 9 | ```xml 10 | 11 | 12 | mirrorId 13 | * 14 | Mirror of central repository. 15 | http://maven.huaweicse.com/nexus/content/groups/public 16 | 17 | 18 | ``` 19 | 20 | 2. mvn clean install 21 | it will generate the WAR file. 22 | 23 | 3. Local service center is required for this demo. 24 | 4. Please copy the WAR file to /tomcatpath/var/lib.. It will automatically deploy the application. 25 | 5. Please check about the API call. 26 | http://127.0.1.1:9093/hello?name=ram 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/src/main/java/io/provider/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package io.provider; 18 | 19 | public interface Hello { 20 | 21 | String sayHi(String name); 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Output Directory 2 | target/ 3 | 4 | # C pre-compile 5 | *.gch 6 | *.pch 7 | 8 | # C compile 9 | *.a 10 | *.o 11 | *.ko 12 | *.la 13 | *.lo 14 | *.obj 15 | *.elf 16 | *.so 17 | *.so.* 18 | *.dylib 19 | *.exe 20 | *.lib 21 | *.dll 22 | *.out 23 | *.app 24 | *.hex 25 | 26 | # Debug files 27 | *.dSYM/ 28 | 29 | # Java 30 | *.class 31 | 32 | # Java Package Files 33 | *.jar 34 | *.war 35 | *.ear 36 | 37 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 38 | hs_err_pid* 39 | 40 | # Zip Files 41 | *.rar 42 | *.zip 43 | *.7z 44 | *.tar 45 | *.gz 46 | 47 | # Ant 48 | build/ 49 | 50 | # Compiled Python 51 | __pycache__/ 52 | *.py[cod] 53 | *py.class 54 | 55 | # Eclipse 56 | .settings/ 57 | .classpath 58 | .project 59 | 60 | # IntelliJ, based on http://devnet.jetbrains.net/docs/DOC-1186 61 | .idea/ 62 | *.iml 63 | *.ipr 64 | *.iws 65 | 66 | # logs and trace 67 | *.log 68 | *.trace 69 | *.dat 70 | 71 | # vi swap 72 | *.swp 73 | 74 | # Backup Files 75 | *.bak 76 | *.old 77 | 78 | # SVN metadata 79 | .svn/ 80 | 81 | # Mac 82 | .DS_Store 83 | -------------------------------------------------------------------------------- /gs-rest-service/run-on-pws.json: -------------------------------------------------------------------------------- 1 | { 2 | "orgName": "spring-guides", 3 | "orgUuid": "", 4 | "spaces": [ 5 | { 6 | "name": "spring-guides", 7 | "routes": [ 8 | { 9 | "name": "random1", 10 | "value": "${random-word}" 11 | } 12 | ], 13 | "apps": [ 14 | { 15 | "name": "rest-service", 16 | "code": { 17 | "url": "https://springio-guides.s3.amazonaws.com/gs-rest-service-0.1.0.jar", 18 | "content_type": "application/war", 19 | "actions": [ 20 | "push" 21 | ] 22 | }, 23 | "instances": 1, 24 | "memory_in_mb": 1024, 25 | "disk_in_mb": 1024, 26 | "map_routes": [ 27 | "random1" 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/src/main/java/hello/SayHelloConfiguration.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.apache.servicecomb.springboot.starter.discovery.ServiceCombServerList; 4 | import org.springframework.context.annotation.Bean; 5 | 6 | import com.netflix.client.config.IClientConfig; 7 | import com.netflix.loadbalancer.AvailabilityFilteringRule; 8 | import com.netflix.loadbalancer.IPing; 9 | import com.netflix.loadbalancer.IRule; 10 | import com.netflix.loadbalancer.PingUrl; 11 | import com.netflix.loadbalancer.Server; 12 | import com.netflix.loadbalancer.ServerList; 13 | 14 | public class SayHelloConfiguration { 15 | @Bean 16 | public IPing ribbonPing(IClientConfig config) { 17 | return new PingUrl(); 18 | } 19 | 20 | @Bean 21 | public IRule ribbonRule(IClientConfig config) { 22 | return new AvailabilityFilteringRule(); 23 | } 24 | 25 | @Bean 26 | ServerList ribbonServerList( 27 | IClientConfig config) { 28 | ServiceCombServerList serverList = new ServiceCombServerList(); 29 | serverList.initWithNiwsConfig(config); 30 | return serverList; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-consumer/src/main/assembly/conf/dubbo.properties: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright 1999-2011 Alibaba Group. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ## 16 | dubbo.container=log4j,spring 17 | dubbo.application.name=demo-consumer 18 | dubbo.application.owner= 19 | dubbo.registry.address=multicast://224.5.6.7:1234 20 | #dubbo.registry.address=zookeeper://127.0.0.1:2181 21 | #dubbo.registry.address=redis://127.0.0.1:6379 22 | #dubbo.registry.address=dubbo://127.0.0.1:9090 23 | dubbo.monitor.protocol=registry 24 | dubbo.log4j.file=logs/dubbo-demo-consumer.log 25 | dubbo.log4j.level=WARN -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/DemoServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2011 Alibaba Group. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.dubbo.demo.provider; 17 | 18 | import com.alibaba.dubbo.demo.DemoService; 19 | import com.alibaba.dubbo.rpc.RpcContext; 20 | 21 | import java.text.SimpleDateFormat; 22 | import java.util.Date; 23 | 24 | public class DemoServiceImpl implements DemoService { 25 | 26 | public String sayHello(String name) { 27 | return "Hello " + name; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/DemoServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2011 Alibaba Group. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.dubbo.demo.provider; 17 | 18 | import org.apache.servicecomb.provider.pojo.RpcSchema; 19 | 20 | import com.alibaba.dubbo.demo.DemoService; 21 | 22 | @RpcSchema(schemaId = "providerSchema") 23 | public class DemoServiceImpl implements DemoService { 24 | 25 | public String sayHello(String name) { 26 | return "Hello " + name; 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-consumer/src/main/assembly/conf/dubbo.properties: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright 1999-2011 Alibaba Group. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ## 16 | dubbo.container=log4j,spring 17 | dubbo.application.name=demo-consumer 18 | dubbo.application.owner= 19 | dubbo.registry.address=multicast://224.5.6.7:1234 20 | #dubbo.registry.address=zookeeper://127.0.0.1:2181 21 | #dubbo.registry.address=redis://127.0.0.1:6379 22 | #dubbo.registry.address=dubbo://127.0.0.1:9090 23 | dubbo.monitor.protocol=registry 24 | dubbo.log4j.file=logs/dubbo-demo-consumer.log 25 | dubbo.log4j.level=WARN -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-provider/src/main/assembly/conf/dubbo.properties: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright 1999-2011 Alibaba Group. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ## 16 | dubbo.container=log4j,spring 17 | dubbo.application.name=demo-provider 18 | dubbo.application.owner= 19 | dubbo.registry.address=multicast://224.5.6.7:1234 20 | #dubbo.registry.address=zookeeper://127.0.0.1:2181 21 | #dubbo.registry.address=redis://127.0.0.1:6379 22 | #dubbo.registry.address=dubbo://127.0.0.1:9090 23 | dubbo.monitor.protocol=registry 24 | dubbo.protocol.name=dubbo 25 | dubbo.protocol.port=20880 26 | dubbo.service.loadbalance=roundrobin 27 | dubbo.log4j.file=logs/dubbo-demo-provider.log 28 | dubbo.log4j.level=WARN -------------------------------------------------------------------------------- /gs-rest-service/complete/src/main/java/hello/GreetingController.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | import com.netflix.config.DynamicPropertyFactory; 5 | 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | public class GreetingController { 13 | 14 | private static final String template = "Hello, %s!"; 15 | 16 | private final AtomicLong counter = new AtomicLong(); 17 | 18 | @Value(value = "${spring.cloud.inject.fault:null}") 19 | private String fault; 20 | 21 | @RequestMapping("/greeting") 22 | public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) { 23 | System.out.println(DynamicPropertyFactory.getInstance().getStringProperty("spring.cloud.inject.fault", null).get()); 24 | if (fault != null) { 25 | return new Greeting(counter.incrementAndGet(), 26 | String.format(template, fault)); 27 | } 28 | return new Greeting(counter.incrementAndGet(), 29 | String.format(template, name)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/src/main/assembly/conf/dubbo.properties: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright 1999-2011 Alibaba Group. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ## 16 | dubbo.container=log4j,spring 17 | dubbo.application.name=demo-provider 18 | dubbo.application.owner= 19 | dubbo.registry.address=multicast://224.5.6.7:1234 20 | #dubbo.registry.address=zookeeper://127.0.0.1:2181 21 | #dubbo.registry.address=redis://127.0.0.1:6379 22 | #dubbo.registry.address=dubbo://127.0.0.1:9090 23 | dubbo.monitor.protocol=registry 24 | dubbo.protocol.name=dubbo 25 | dubbo.protocol.port=20880 26 | dubbo.service.loadbalance=roundrobin 27 | dubbo.log4j.file=logs/dubbo-demo-provider.log 28 | dubbo.log4j.level=WARN -------------------------------------------------------------------------------- /spring-boot-tomcat-war-deploy/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | APPLICATION_ID: spring-boot 4 | service_description: 5 | name: spring-boot-simple 6 | version: 0.0.1 7 | 8 | cse: 9 | 10 | # for local test 11 | service: 12 | registry: 13 | address: http://127.0.0.1:30100 14 | instance: 15 | watch: true 16 | healthCheck: 17 | interval: 5 18 | 19 | # for cloud service 20 | # config: 21 | # client: 22 | # refreshMode: 1 23 | # service: 24 | # registry: 25 | # address: https://cse.cn-north-1.myhwclouds.com:443 26 | # instance: 27 | # watch: false 28 | # config: 29 | # client: 30 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 31 | # refreshMode: 1 32 | # refresh_interval: 15000 33 | # monitor: 34 | # client: 35 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 36 | # credentials: 37 | # accessKey: your access key 38 | # secretKey: your secret key 39 | # akskCustomCipher: default 40 | 41 | rest: 42 | address: 0.0.0.0:9093 43 | 44 | credentials: 45 | accessKey: your ak 46 | secretKey: yours sk 47 | akskCustomCipher: default 48 | 49 | servicecomb: 50 | rest: 51 | servlet: 52 | urlPattern: /servicecomb/rest/* -------------------------------------------------------------------------------- /spring-boot-simple/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | APPLICATION_ID: spring-boot 4 | service_description: 5 | name: spring-boot-simple 6 | version: 0.0.1 7 | 8 | cse: 9 | 10 | # for local test 11 | service: 12 | registry: 13 | address: https://cse.cn-north-1.myhwclouds.com:443 14 | instance: 15 | watch: false 16 | healthCheck: 17 | interval: 5 18 | 19 | # for cloud service 20 | # config: 21 | # client: 22 | # refreshMode: 1 23 | # service: 24 | # registry: 25 | # address: https://cse.cn-north-1.myhwclouds.com:443 26 | # instance: 27 | # watch: false 28 | config: 29 | client: 30 | serverUri: https://cse.cn-north-1.myhwclouds.com:443 31 | refreshMode: 1 32 | refresh_interval: 15000 33 | # monitor: 34 | # client: 35 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 36 | # credentials: 37 | # accessKey: your access key 38 | # secretKey: your secret key 39 | # akskCustomCipher: default 40 | 41 | rest: 42 | address: 0.0.0.0:9093 43 | 44 | credentials: 45 | accessKey: your ak 46 | secretKey: yours sk 47 | akskCustomCipher: default 48 | 49 | servicecomb: 50 | rest: 51 | servlet: 52 | urlPattern: /servicecomb/rest/* -------------------------------------------------------------------------------- /spring-boot-web/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | APPLICATION_ID: spring-boot 4 | service_description: 5 | name: spring-boot-simple 6 | version: 0.0.1 7 | 8 | cse: 9 | 10 | # for local test 11 | service: 12 | registry: 13 | address: https://cse.cn-north-1.myhwclouds.com:443 14 | instance: 15 | watch: false 16 | healthCheck: 17 | interval: 5 18 | 19 | # for cloud service 20 | # config: 21 | # client: 22 | # refreshMode: 1 23 | # service: 24 | # registry: 25 | # address: https://cse.cn-north-1.myhwclouds.com:443 26 | # instance: 27 | # watch: false 28 | config: 29 | client: 30 | serverUri: https://cse.cn-north-1.myhwclouds.com:443 31 | refreshMode: 1 32 | refresh_interval: 15000 33 | # monitor: 34 | # client: 35 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 36 | # credentials: 37 | # accessKey: your access key 38 | # secretKey: your secret key 39 | # akskCustomCipher: default 40 | 41 | rest: 42 | address: 0.0.0.0:8080 43 | 44 | credentials: 45 | accessKey: your access key 46 | secretKey: your secret key 47 | akskCustomCipher: default 48 | 49 | servicecomb: 50 | rest: 51 | servlet: 52 | urlPattern: /servicecomb/rest/* 53 | 54 | server: 55 | port: 9999 -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/user/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.5.9.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'eclipse' 15 | apply plugin: 'org.springframework.boot' 16 | 17 | jar { 18 | baseName = 'user' 19 | version = '0.0.1-SNAPSHOT' 20 | } 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | repositories { 25 | mavenCentral() 26 | maven { url "https://repo.spring.io/snapshot" } 27 | maven { url "https://repo.spring.io/milestone" } 28 | } 29 | 30 | 31 | dependencies { 32 | compile('org.springframework.cloud:spring-cloud-starter-ribbon') 33 | compile('org.springframework.boot:spring-boot-starter-web') 34 | testCompile('org.springframework.boot:spring-boot-starter-test') 35 | } 36 | 37 | dependencyManagement { 38 | imports { 39 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE" 40 | } 41 | } 42 | 43 | 44 | eclipse { 45 | classpath { 46 | containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') 47 | containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.5.9.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'eclipse' 15 | apply plugin: 'org.springframework.boot' 16 | 17 | jar { 18 | baseName = 'user' 19 | version = '0.0.1-SNAPSHOT' 20 | } 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | repositories { 25 | mavenCentral() 26 | maven { url "https://repo.spring.io/snapshot" } 27 | maven { url "https://repo.spring.io/milestone" } 28 | } 29 | 30 | 31 | dependencies { 32 | compile('org.springframework.cloud:spring-cloud-starter-ribbon') 33 | compile('org.springframework.boot:spring-boot-starter-web') 34 | testCompile('org.springframework.boot:spring-boot-starter-test') 35 | } 36 | 37 | dependencyManagement { 38 | imports { 39 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE" 40 | } 41 | } 42 | 43 | 44 | eclipse { 45 | classpath { 46 | containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') 47 | containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/provider/src/main/java/hello/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.ServiceInstance; 7 | import org.springframework.cloud.client.discovery.DiscoveryClient; 8 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.List; 14 | 15 | @EnableDiscoveryClient 16 | @SpringBootApplication 17 | public class ProviderApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(ProviderApplication.class, args); 21 | } 22 | } 23 | 24 | @RestController 25 | class ServiceInstanceRestController { 26 | 27 | @Autowired 28 | private DiscoveryClient discoveryClient; 29 | 30 | @RequestMapping("/service-instances/{applicationName}") 31 | public List serviceInstancesByApplicationName( 32 | @PathVariable String applicationName) { 33 | return this.discoveryClient.getInstances(applicationName); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-api/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 4.0.0 19 | 20 | com.alibaba 21 | dubbo-demo 22 | 2.5.7 23 | 24 | dubbo-demo-api 25 | jar 26 | ${project.artifactId} 27 | The demo module of dubbo project 28 | 29 | true 30 | 31 | -------------------------------------------------------------------------------- /gs-rest-service-with-servicecomb/complete/src/main/java/hello/GreetingController.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | 10 | import org.apache.servicecomb.provider.rest.common.RestSchema; 11 | 12 | @RestSchema(schemaId = "greeting") 13 | @RequestMapping(path = "/") 14 | public class GreetingController implements IGreetingController { 15 | 16 | private static final String template = "Hello, %s!"; 17 | 18 | private final AtomicLong counter = new AtomicLong(); 19 | 20 | @Value(value = "${spring.cloud.inject.fault:null}") 21 | private String fault; 22 | 23 | @Override 24 | @RequestMapping(value = "/greeting", method = RequestMethod.GET) 25 | public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) { 26 | // String fault = DynamicPropertyFactory.getInstance().getStringProperty("spring.cloud.inject.fault", null).get(); 27 | // if (fault != null) { 28 | // return new Greeting(counter.incrementAndGet(), 29 | // String.format(template, fault)); 30 | // } 31 | return new Greeting(counter.incrementAndGet(), 32 | String.format(template, name)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-api/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 4.0.0 19 | 20 | com.alibaba 21 | dubbo-demo 22 | 2.5.7 23 | 24 | dubbo-demo-api-servicecomb 25 | jar 26 | ${project.artifactId} 27 | The demo module of dubbo project 28 | 29 | true 30 | 31 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-consumer/src/main/java/io/consumer/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package io.consumer; 18 | 19 | 20 | import org.springframework.cloud.netflix.feign.FeignClient; 21 | import org.springframework.web.bind.annotation.RequestMapping; 22 | import org.springframework.web.bind.annotation.RequestMethod; 23 | import org.springframework.web.bind.annotation.RequestParam; 24 | 25 | @FeignClient("helloprovider") 26 | @RequestMapping(path = "/hello") 27 | public interface Hello { 28 | 29 | @RequestMapping(path = "/sayhi", method = RequestMethod.GET) 30 | String sayHi(@RequestParam(name = "name") String name); 31 | } 32 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/src/main/java/io/consumer/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package io.consumer; 18 | 19 | 20 | import org.springframework.cloud.netflix.feign.FeignClient; 21 | import org.springframework.web.bind.annotation.RequestMapping; 22 | import org.springframework.web.bind.annotation.RequestMethod; 23 | import org.springframework.web.bind.annotation.RequestParam; 24 | 25 | @FeignClient("helloprovider") 26 | @RequestMapping(path = "/hello") 27 | public interface Hello { 28 | 29 | @RequestMapping(path = "/sayhi", method = RequestMethod.GET) 30 | String sayHi(@RequestParam(name = "name") String name); 31 | } 32 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 4.0.0 19 | com.alibaba 20 | dubbo-demo 21 | 2.5.7 22 | pom 23 | ${project.artifactId} 24 | The demo module of dubbo project 25 | 26 | true 27 | 28 | 29 | 30 | dubbo-demo-api 31 | dubbo-demo-provider 32 | dubbo-demo-consumer 33 | 34 | 35 | -------------------------------------------------------------------------------- /gs-rest-service-with-servicecomb/complete/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.ImportResource; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | import io.servicecomb.provider.pojo.RpcReference; 11 | import io.servicecomb.provider.springmvc.reference.RestTemplateBuilder; 12 | import io.servicecomb.springboot.starter.provider.EnableServiceComb; 13 | 14 | @SpringBootApplication 15 | @EnableAutoConfiguration 16 | @EnableServiceComb 17 | @Component 18 | public class Application { 19 | 20 | @RpcReference(microserviceName = "spring-cloud-with-servicecomb-demo", schemaId = "greeting") 21 | private static IGreetingController hello; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(Application.class, args); 25 | 26 | // call demo 27 | RestTemplate restTemplate = RestTemplateBuilder.create(); 28 | Greeting result = restTemplate.getForEntity("cse://spring-cloud-with-servicecomb-demo/greeting", Greeting.class).getBody(); 29 | System.out.println("result: " + result.getContent()); 30 | 31 | result = hello.greeting("test for rpc"); 32 | System.out.println("result: " + result.getContent()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-consumer 10 | 11 | UTF-8 12 | 1.8 13 | 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-web 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-feign 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-eureka 27 | 28 | 29 | 30 | javax.ws.rs 31 | jsr311-api 32 | 1.1.1 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-provider 10 | 11 | 12 | UTF-8 13 | 1.8 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-web 20 | 21 | 22 | org.springframework.cloud 23 | spring-cloud-starter-feign 24 | 25 | 26 | org.springframework.cloud 27 | spring-cloud-starter-eureka 28 | 29 | 30 | 31 | javax.ws.rs 32 | jsr311-api 33 | 1.1.1 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/consumer/src/main/java/hello/ServiceInstanceImpl.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.net.URI; 4 | import java.util.Map; 5 | 6 | import org.springframework.cloud.client.ServiceInstance; 7 | 8 | public class ServiceInstanceImpl implements ServiceInstance { 9 | private String serviceId; 10 | private String host; 11 | private int port; 12 | private boolean secure; 13 | private URI uri; 14 | private Map metadata; 15 | 16 | @Override 17 | public String getServiceId() { 18 | return serviceId; 19 | } 20 | 21 | public void setServiceId(String serviceId) { 22 | this.serviceId = serviceId; 23 | } 24 | 25 | @Override 26 | public String getHost() { 27 | return host; 28 | } 29 | 30 | public void setHost(String host) { 31 | this.host = host; 32 | } 33 | 34 | @Override 35 | public int getPort() { 36 | return port; 37 | } 38 | 39 | public void setPort(int port) { 40 | this.port = port; 41 | } 42 | 43 | @Override 44 | public boolean isSecure() { 45 | return secure; 46 | } 47 | 48 | public void setSecure(boolean secure) { 49 | this.secure = secure; 50 | } 51 | 52 | @Override 53 | public URI getUri() { 54 | return uri; 55 | } 56 | 57 | public void setUri(URI uri) { 58 | this.uri = uri; 59 | } 60 | 61 | @Override 62 | public Map getMetadata() { 63 | return metadata; 64 | } 65 | 66 | public void setMetadata(Map metadata) { 67 | this.metadata = metadata; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-consumer 10 | 11 | UTF-8 12 | 1.8 13 | 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-web 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-feign 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | javax.ws.rs 31 | jsr311-api 32 | 1.1.1 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-provider 10 | 11 | 12 | UTF-8 13 | 1.8 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-web 20 | 21 | 22 | org.springframework.cloud 23 | spring-cloud-starter-feign 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | javax.ws.rs 32 | jsr311-api 33 | 1.1.1 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-consumer/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | assembly 18 | 19 | tar.gz 20 | 21 | true 22 | 23 | 24 | ${project.build.directory}/dubbo/META-INF/assembly/bin 25 | bin 26 | 0755 27 | 28 | 29 | src/main/assembly/conf 30 | conf 31 | 0644 32 | 33 | 34 | 35 | 36 | lib 37 | 38 | 39 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-provider/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | assembly 18 | 19 | tar.gz 20 | 21 | true 22 | 23 | 24 | ${project.build.directory}/dubbo/META-INF/assembly/bin 25 | bin 26 | 0755 27 | 28 | 29 | src/main/assembly/conf 30 | conf 31 | 0644 32 | 33 | 34 | 35 | 36 | lib 37 | 38 | 39 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-consumer/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | assembly 18 | 19 | tar.gz 20 | 21 | true 22 | 23 | 24 | ${project.build.directory}/dubbo/META-INF/assembly/bin 25 | bin 26 | 0755 27 | 28 | 29 | src/main/assembly/conf 30 | conf 31 | 0644 32 | 33 | 34 | 35 | 36 | lib 37 | 38 | 39 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | assembly 18 | 19 | tar.gz 20 | 21 | true 22 | 23 | 24 | ${project.build.directory}/dubbo/META-INF/assembly/bin 25 | bin 26 | 0755 27 | 28 | 29 | src/main/assembly/conf 30 | conf 31 | 0644 32 | 33 | 34 | 35 | 36 | lib 37 | 38 | 39 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-consumer/src/main/java/io/consumer/HelloService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.consumer; 17 | 18 | import javax.ws.rs.core.MediaType; 19 | 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.web.bind.annotation.RequestMapping; 23 | import org.springframework.web.bind.annotation.RequestMethod; 24 | import org.springframework.web.bind.annotation.RestController; 25 | 26 | @RestController 27 | @RequestMapping(path = "/hello", produces = MediaType.TEXT_PLAIN) 28 | public class HelloService { 29 | private static org.slf4j.Logger log = LoggerFactory.getLogger(HelloService.class); 30 | 31 | @Autowired 32 | Hello client; 33 | 34 | @RequestMapping(method = RequestMethod.GET) 35 | public String hello(String name) { 36 | log.info("Access /hello, and name is " + name); 37 | return client.sayHi(name); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/src/main/java/io/consumer/HelloService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.consumer; 17 | 18 | import javax.ws.rs.core.MediaType; 19 | 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.web.bind.annotation.RequestMapping; 23 | import org.springframework.web.bind.annotation.RequestMethod; 24 | import org.springframework.web.bind.annotation.RestController; 25 | 26 | @RestController 27 | @RequestMapping(path = "/hello", produces = MediaType.TEXT_PLAIN) 28 | public class HelloService { 29 | private static org.slf4j.Logger log = LoggerFactory.getLogger(HelloService.class); 30 | 31 | @Autowired 32 | Hello client; 33 | 34 | @RequestMapping(method = RequestMethod.GET) 35 | public String hello(String name) { 36 | log.info("Access /hello, and name is " + name); 37 | return client.sayHi(name); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/say-hello/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | hello 7 | say-hello 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | say-hello 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-consumer/README.md: -------------------------------------------------------------------------------- 1 | ## 服务消费者接入CSE 2 | 3 | 这里我们基于原始Spring Cloud应用,演示如何接入CSE 4 | 详细文档可参考[Spring Cloud应用接入CSE](https://support.huaweicloud.com/bestpractice-cse/cse_03_0092.html) 5 | 6 | ### 启动服务 7 | 直接运行ClientMain的main函数 8 | 9 | 访问[http://localhost:7211/hello?name=springcloud](http://localhost:7211/hello?name=springcloud),调用helloconsumer服务/hello接口(消费helloprovider) 10 | 11 | 12 | ### 本地调试 13 | 本地运行需要在src/main/resources下的application文件中增加如下配置: 14 | 15 | application.yml: 16 | 17 | ```yml 18 | cse: 19 | credentials: 20 | accessKey: your access key 21 | secretKey: your secret key 22 | akskCustomCipher: default 23 | project: cn-north-1 24 | ``` 25 | 26 | application.properties: 27 | 28 | ```property 29 | cse.credentials.accessKey=your access key 30 | cse.credentials.secretKey=your secret key 31 | cse.credentials.akskCustomCipher=default 32 | cse.credentials.project=cn-north-1 33 | ``` 34 | 其中: 35 | 36 | * cse.credentials.accessKey: 用户华为云账户AK 37 | * cse.credentials.secretKey: 用户华为云账户SK 38 | * cse.credentials.akskCustomCipher: AKSK存储方式,默认default为明文存储,查看[更多](https://support.huaweicloud.com/devg-cse/cse_03_0088.html) 39 | * cse.credentials.project:注册Region,默认为华北区cn-north-1 40 | 41 | ### 镜像构建 42 | a. 已提供Dockerfile和start.sh,可以直接在华为云微服务云平台[创建构建Job](https://servicestage.huaweicloud.com/servicestage/?project=cn-north-1#/pipeline/createjob)和[流水线](https://servicestage.huaweicloud.com/servicestage/?project=cn-north-1#/pipeline/create?from=pipeline.list) 43 | 44 | b. 华为云微服务平台编译时默认使用自带的maven仓库,若使用自定义的maven仓库,可参考以下两种方法: 1、请将您的settings.xml存放到该项目的代码库根目录下; 2、在该项目的pom文件中设置用户repositories配置。 45 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/README.md: -------------------------------------------------------------------------------- 1 | ## 服务提供者接入CSE 2 | 3 | 这里我们基于原始Spring Cloud应用,演示如何接入CSE 4 | 详细文档可参考[Spring Cloud应用接入CSE](https://support.huaweicloud.com/bestpractice-cse/cse_03_0092.html) 5 | 6 | ### 启动服务 7 | 直接运行ServerMain的main函数 8 | 9 | 访问[http://localhost:7111/hello/sayhi?name=springcloud](http://localhost:7111/hello/sayhi?name=springcloud),调用helloprovider服务/hello/sayhi接口 10 | 11 | 12 | ### 本地调试 13 | 本地运行需要在src/main/resources下的application文件中增加如下配置: 14 | 15 | application.yml: 16 | 17 | ```yml 18 | cse: 19 | credentials: 20 | accessKey: your access key 21 | secretKey: your secret key 22 | akskCustomCipher: default 23 | project: cn-north-1 24 | ``` 25 | 26 | application.properties: 27 | 28 | ```property 29 | cse.credentials.accessKey=your access key 30 | cse.credentials.secretKey=your secret key 31 | cse.credentials.akskCustomCipher=default 32 | cse.credentials.project=cn-north-1 33 | ``` 34 | 其中: 35 | 36 | * cse.credentials.accessKey: 用户华为云账户AK 37 | * cse.credentials.secretKey: 用户华为云账户SK 38 | * cse.credentials.akskCustomCipher: AKSK存储方式,默认default为明文存储,查看[更多](https://support.huaweicloud.com/devg-cse/cse_03_0088.html) 39 | * cse.credentials.project:注册Region,默认为华北区cn-north-1 40 | 41 | ### 镜像构建 42 | a. 已提供Dockerfile和start.sh,可以直接在华为云微服务云平台[创建构建Job](https://servicestage.huaweicloud.com/servicestage/?project=cn-north-1#/pipeline/createjob)和[流水线](https://servicestage.huaweicloud.com/servicestage/?project=cn-north-1#/pipeline/create?from=pipeline.list) 43 | 44 | b. 华为云微服务平台编译时默认使用自带的maven仓库,若使用自定义的maven仓库,可参考以下两种方法: 1、请将您的settings.xml存放到该项目的代码库根目录下; 2、在该项目的pom文件中设置用户repositories配置。 45 | 46 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/say-hello/src/main/java/hello/SayHelloApplication.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.boot.SpringApplication; 11 | import org.springframework.boot.autoconfigure.SpringBootApplication; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import com.netflix.config.DynamicPropertyFactory; 16 | 17 | @RestController 18 | @SpringBootApplication 19 | public class SayHelloApplication { 20 | 21 | private static Logger log = LoggerFactory.getLogger(SayHelloApplication.class); 22 | 23 | @Value(value = "${cse.dynamic.fault:null}") 24 | private String fault; 25 | 26 | @RequestMapping(value = "/greeting") 27 | public String greet() { 28 | log.info("Access /greeting"); 29 | 30 | List greetings = Arrays.asList("Hi there", "Greetings", "Salutations"); 31 | Random rand = new Random(); 32 | 33 | int randomNum = rand.nextInt(greetings.size()); 34 | return greetings.get(randomNum) + " fault is " + fault + 35 | " dynamic fault is " + 36 | DynamicPropertyFactory.getInstance().getStringProperty("cse.dynamic.fault", null).get(); 37 | } 38 | 39 | @RequestMapping(value = "/") 40 | public String home() { 41 | log.info("Access /"); 42 | return "Hi!"; 43 | } 44 | 45 | public static void main(String[] args) { 46 | SpringApplication.run(SayHelloApplication.class, args); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/src/test/java/demo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.Map; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.boot.test.IntegrationTest; 11 | import org.springframework.boot.test.SpringApplicationConfiguration; 12 | import org.springframework.boot.test.TestRestTemplate; 13 | import org.springframework.http.HttpStatus; 14 | import org.springframework.http.ResponseEntity; 15 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 16 | import org.springframework.test.context.web.WebAppConfiguration; 17 | import org.springframework.util.LinkedMultiValueMap; 18 | import org.springframework.util.MultiValueMap; 19 | 20 | @RunWith(SpringJUnit4ClassRunner.class) 21 | @SpringApplicationConfiguration(classes = ConfigServerApplication.class) 22 | @WebAppConfiguration 23 | @IntegrationTest("server.port=0") 24 | public class ApplicationTests { 25 | 26 | @Value("${local.server.port}") 27 | private int port = 0; 28 | 29 | @Test 30 | public void configurationAvailable() { 31 | @SuppressWarnings("rawtypes") 32 | ResponseEntity entity = new TestRestTemplate().getForEntity( 33 | "http://localhost:" + port + "/app/cloud", Map.class); 34 | assertEquals(HttpStatus.OK, entity.getStatusCode()); 35 | } 36 | 37 | @Test 38 | public void envPostAvailable() { 39 | MultiValueMap form = new LinkedMultiValueMap(); 40 | @SuppressWarnings("rawtypes") 41 | ResponseEntity entity = new TestRestTemplate().postForEntity( 42 | "http://localhost:" + port + "/admin/env", form, Map.class); 43 | assertEquals(HttpStatus.OK, entity.getStatusCode()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-provider/src/main/java/io/provider/HelloService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package io.provider; 19 | 20 | import javax.ws.rs.core.MediaType; 21 | 22 | import org.slf4j.LoggerFactory; 23 | import org.springframework.web.bind.annotation.RequestMapping; 24 | import org.springframework.web.bind.annotation.RequestMethod; 25 | import org.springframework.web.bind.annotation.RequestParam; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | @RestController 29 | @RequestMapping(path = "/hello", produces = MediaType.TEXT_PLAIN) 30 | public class HelloService implements Hello { 31 | private static org.slf4j.Logger log = LoggerFactory.getLogger(HelloService.class); 32 | 33 | @Override 34 | @RequestMapping(path = "/sayhi", method = RequestMethod.GET) 35 | public String sayHi(@RequestParam(name = "name", required = false) String name) { 36 | log.info("Access /hello/sayhi, and name is " + name); 37 | return "from provider: Hello " + name; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/springcloud-provider/src/main/java/io/provider/HelloService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package io.provider; 19 | 20 | import javax.ws.rs.core.MediaType; 21 | 22 | import org.slf4j.LoggerFactory; 23 | import org.springframework.web.bind.annotation.RequestMapping; 24 | import org.springframework.web.bind.annotation.RequestMethod; 25 | import org.springframework.web.bind.annotation.RequestParam; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | @RestController 29 | @RequestMapping(path = "/hello", produces = MediaType.TEXT_PLAIN) 30 | public class HelloService implements Hello { 31 | private static org.slf4j.Logger log = LoggerFactory.getLogger(HelloService.class); 32 | 33 | @Override 34 | @RequestMapping(path = "/sayhi", method = RequestMethod.GET) 35 | public String sayHi(@RequestParam(name = "name", required = false) String name) { 36 | log.info("Access /hello/sayhi, and name is " + name); 37 | return "from provider: Hello " + name; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 4.0.0 20 | com.alibaba 21 | dubbo-demo-servicecomb 22 | 2.5.7 23 | pom 24 | ${project.artifactId} 25 | The demo module of dubbo project 26 | 27 | true 28 | 29 | 30 | 31 | 32 | 33 | com.huawei.paas.cse 34 | cse-dependency 35 | 2.3.9 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | com.huawei.paas.cse 44 | cse-solution-service-engine 45 | 46 | 47 | 48 | dubbo-demo-api 49 | dubbo-demo-provider 50 | dubbo-demo-consumer 51 | 52 | 53 | -------------------------------------------------------------------------------- /springcloud-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.case 7 | springcloud-sample 8 | 0.0.1-SNAPSHOT 9 | pom 10 | 11 | springcloud-sample 12 | Demo project for Spring Cloud 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | springcloud-provider 23 | springcloud-consumer 24 | eureka-server 25 | 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | 1.8 31 | Edgware.RELEASE 32 | 33 | 34 | 35 | 36 | org.springframework.cloud 37 | spring-cloud-starter-eureka-server 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.cloud 51 | spring-cloud-dependencies 52 | Edgware.RELEASE 53 | pom 54 | import 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /gs-rest-service/initial/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-rest-service 8 | 0.1.0 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 1.5.9.RELEASE 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-web 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-test 24 | test 25 | 26 | 27 | com.jayway.jsonpath 28 | json-path 29 | test 30 | 31 | 32 | 33 | 34 | 1.8 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | 49 | spring-releases 50 | https://repo.spring.io/libs-release 51 | 52 | 53 | 54 | 55 | spring-releases 56 | https://repo.spring.io/libs-release 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/registry/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | registry 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | 19 | UTF-8 20 | 1.8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-eureka-server 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-test 32 | test 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-dependencies 41 | Edgware.RELEASE 42 | pom 43 | import 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 54 | 55 | 56 | 57 | 58 | 59 | spring-snapshots 60 | Spring Snapshots 61 | https://repo.spring.io/libs-snapshot 62 | 63 | true 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /springcloud-sample-2-cse/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.case 7 | springcloud-sample 8 | 0.0.1-SNAPSHOT 9 | pom 10 | 11 | springcloud-sample 12 | Demo project for Spring Cloud 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | springcloud-provider 23 | springcloud-consumer 24 | 25 | 26 | 27 | UTF-8 28 | UTF-8 29 | 1.8 30 | Edgware.RELEASE 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | com.huawei.paas.cse 40 | cse-solution-spring-cloud 41 | 2.3.20 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.cloud 54 | spring-cloud-dependencies 55 | Edgware.RELEASE 56 | pom 57 | import 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/provider/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | provider 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | 19 | UTF-8 20 | 1.8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-eureka 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-test 32 | test 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-eureka-server 37 | test 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-dependencies 46 | Edgware.RELEASE 47 | pom 48 | import 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-maven-plugin 58 | 59 | 60 | 61 | 62 | 63 | 64 | spring-snapshots 65 | Spring Snapshots 66 | https://repo.spring.io/libs-snapshot 67 | 68 | true 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /gs-rest-service/complete/src/test/java/hello/GreetingControllerTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package hello; 17 | 18 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 19 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; 20 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 21 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 22 | 23 | import org.junit.Test; 24 | import org.junit.runner.RunWith; 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 27 | import org.springframework.boot.test.context.SpringBootTest; 28 | import org.springframework.test.context.junit4.SpringRunner; 29 | import org.springframework.test.web.servlet.MockMvc; 30 | 31 | @RunWith(SpringRunner.class) 32 | @SpringBootTest 33 | @AutoConfigureMockMvc 34 | public class GreetingControllerTests { 35 | 36 | @Autowired 37 | private MockMvc mockMvc; 38 | 39 | @Test 40 | public void noParamGreetingShouldReturnDefaultMessage() throws Exception { 41 | 42 | this.mockMvc.perform(get("/greeting")).andDo(print()).andExpect(status().isOk()) 43 | .andExpect(jsonPath("$.content").value("Hello, World!")); 44 | } 45 | 46 | @Test 47 | public void paramGreetingShouldReturnTailoredMessage() throws Exception { 48 | 49 | this.mockMvc.perform(get("/greeting").param("name", "Spring Community")) 50 | .andDo(print()).andExpect(status().isOk()) 51 | .andExpect(jsonPath("$.content").value("Hello, Spring Community!")); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /gs-rest-service-with-servicecomb/complete/src/test/java/hello/GreetingControllerTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package hello; 17 | 18 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 19 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; 20 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 21 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 22 | 23 | import org.junit.Test; 24 | import org.junit.runner.RunWith; 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 27 | import org.springframework.boot.test.context.SpringBootTest; 28 | import org.springframework.test.context.junit4.SpringRunner; 29 | import org.springframework.test.web.servlet.MockMvc; 30 | 31 | @RunWith(SpringRunner.class) 32 | @SpringBootTest 33 | @AutoConfigureMockMvc 34 | public class GreetingControllerTests { 35 | 36 | @Autowired 37 | private MockMvc mockMvc; 38 | 39 | @Test 40 | public void noParamGreetingShouldReturnDefaultMessage() throws Exception { 41 | 42 | this.mockMvc.perform(get("/greeting")).andDo(print()).andExpect(status().isOk()) 43 | .andExpect(jsonPath("$.content").value("Hello, World!")); 44 | } 45 | 46 | @Test 47 | public void paramGreetingShouldReturnTailoredMessage() throws Exception { 48 | 49 | this.mockMvc.perform(get("/greeting").param("name", "Spring Community")) 50 | .andDo(print()).andExpect(status().isOk()) 51 | .andExpect(jsonPath("$.content").value("Hello, Spring Community!")); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/say-hello/src/test/java/hello/SayHelloApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package hello; 17 | 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.boot.context.embedded.LocalServerPort; 22 | import org.springframework.boot.test.context.SpringBootTest; 23 | import org.springframework.boot.test.web.client.TestRestTemplate; 24 | import org.springframework.http.HttpStatus; 25 | import org.springframework.http.ResponseEntity; 26 | import org.springframework.test.context.junit4.SpringRunner; 27 | 28 | import static org.assertj.core.api.BDDAssertions.then; 29 | 30 | @RunWith(SpringRunner.class) 31 | @SpringBootTest(classes = SayHelloApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 32 | public class SayHelloApplicationTests { 33 | 34 | @LocalServerPort 35 | private int port; 36 | 37 | @Autowired 38 | private TestRestTemplate testRestTemplate; 39 | 40 | @Test 41 | public void shouldReturn200WhenSendingRequestToRoot() throws Exception { 42 | @SuppressWarnings("rawtypes") ResponseEntity entity = this.testRestTemplate.getForEntity( 43 | "http://localhost:" + this.port + "/", String.class); 44 | 45 | then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); 46 | then(entity.getBody()).isEqualTo("Hi!"); 47 | } 48 | 49 | @Test 50 | public void shouldReturn200WhenSendingRequestToGreeting() throws Exception { 51 | @SuppressWarnings("rawtypes") ResponseEntity entity = this.testRestTemplate.getForEntity( 52 | "http://localhost:" + this.port + "/greeting", String.class); 53 | 54 | then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); 55 | then(entity.getBody()).isNotEmpty(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-tomcat-war-deploy/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 1.4.5.RELEASE 11 | 12 | 13 | com.huawei.cse.sample 14 | spring-boot-simple 15 | 0.0.1-SNAPSHOT 16 | war 17 | 18 | 19 | 20 | 21 | com.huawei.paas.cse 22 | cse-dependency 23 | 2.3.12 24 | pom 25 | import 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-tomcat 34 | provided 35 | 36 | 37 | org.apache.servicecomb 38 | spring-boot-starter-provider 39 | 40 | 41 | com.huawei.paas.cse 42 | cse-solution-service-engine 43 | 44 | 45 | org.slf4j 46 | slf4j-log4j12 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter 53 | 54 | 55 | org.hibernate 56 | hibernate-validator 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.apache.maven.plugins 64 | maven-compiler-plugin 65 | 66 | 1.8 67 | 1.8 68 | 69 | 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-maven-plugin 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | consumer 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | 19 | UTF-8 20 | 1.8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-eureka 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-feign 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-eureka-server 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-dependencies 50 | Edgware.RELEASE 51 | pom 52 | import 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | 67 | 68 | spring-snapshots 69 | Spring Snapshots 70 | https://repo.spring.io/libs-snapshot 71 | 72 | true 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /spring-cloud-config-server-orginal/README.md: -------------------------------------------------------------------------------- 1 | # Config Server Sample 2 | 3 | NOTE: This project requires rabbitmq running on localhost. 4 | 5 | Run this project as a Spring Boot app, e.g. import into IDE and run 6 | main method, or use Maven: 7 | 8 | ``` 9 | $ ./mvnw spring-boot:run 10 | ``` 11 | 12 | or 13 | 14 | ``` 15 | $ ./mvnw package 16 | $ java -jar target/*.jar 17 | ``` 18 | 19 | It will start up on port 8888 and serve configuration data from 20 | "https://github.com/spring-cloud-samples/config-repo": 21 | 22 | ## Pre-requisites 23 | 24 | You need to be running rabbitmq locally (there is a `docker-compose.yml` if you would 25 | like to use that). This is to support broadcast of config changes to client apps 26 | via Spring Cloud Stream. If you want to play and don't need that feature just 27 | comment out the monitor and rabbitmq dependencies. 28 | 29 | ## Resources 30 | 31 | | Path | Description | 32 | |------------------|--------------| 33 | | /{app}/{profile} | Configuration data for app in Spring profile (comma-separated).| 34 | | /{app}/{profile}/{label} | Add a git label | 35 | | /{app}/{profiels}{label}/{path} | An environment-specific plain text config file (at "path") | 36 | 37 | ## Security 38 | 39 | The server is not secure by default. You can add HTTP Basic 40 | authentication by including an extra dependency on Spring Security 41 | (e.g. via `spring-boot-starter-security`). The user name is "user" and 42 | the password is printed on the console on startup (standard Spring 43 | Boot approach), e.g. 44 | 45 | ``` 46 | 2014-10-23 08:55:01.579 INFO 8185 --- [ main] b.a.s.AuthenticationManagerConfiguration : 47 | 48 | Using default security password: 83805c57-8c76-4940-ae17-299359888177 49 | 50 | 51 | ``` 52 | 53 | There is also a password stored in a keystore in the jar file if you 54 | want to use that for a more realistic simulation of a real system. To 55 | unlock the password you need the full strength JCE extensions 56 | (download from Oracle and unpack the zip then copy the jar files to 57 | `/jre/lib/security`), and the keystore password ("foobar" 58 | stored in plain text in this README for the purposes of a demo, but in 59 | a real system you would keep it secret and only expose via environment 60 | variables). The password is bound to the app from the Spring 61 | environment key `keystore.password` (so an OS environment variable 62 | KEYSTORE_PASSWORD works). E.g. 63 | 64 | ``` 65 | $ KEYSTORE_PASSWORD=foobar java -jar target/*.jar 66 | ``` 67 | -------------------------------------------------------------------------------- /spring-boot-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 1.4.5.RELEASE 10 | 11 | 12 | com.huawei.cse.sample 13 | spring-boot-web 14 | 0.0.1-SNAPSHOT 15 | jar 16 | 17 | 18 | 19 | 20 | com.huawei.paas.cse 21 | cse-dependency 22 | 2.3.18 23 | pom 24 | import 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.servicecomb 32 | spring-boot-starter-transport 33 | 34 | 35 | com.huawei.paas.cse 36 | cse-solution-service-engine 37 | 38 | 39 | org.slf4j 40 | slf4j-log4j12 41 | 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-web 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-compiler-plugin 55 | 56 | 1.8 57 | 1.8 58 | 59 | 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-maven-plugin 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | hello 7 | user 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | user 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-ribbon 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.cloud 47 | spring-cloud-dependencies 48 | Edgware.RELEASE 49 | pom 50 | import 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-maven-plugin 60 | 61 | 62 | 63 | 64 | 65 | 66 | spring-snapshots 67 | Spring Snapshots 68 | https://repo.spring.io/snapshot 69 | 70 | true 71 | 72 | 73 | 74 | spring-milestones 75 | Spring Milestones 76 | https://repo.spring.io/milestone 77 | 78 | false 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /spring-cloud-with-eureka-demo/consumer/src/main/java/hello/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.ExecutionException; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.cloud.client.ServiceInstance; 10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 11 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 12 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | import org.springframework.web.client.AsyncRestTemplate; 17 | import org.springframework.web.client.RestTemplate; 18 | 19 | @EnableDiscoveryClient 20 | @EnableFeignClients 21 | @SpringBootApplication 22 | public class ConsumerApplication { 23 | @LoadBalanced 24 | @Bean 25 | public RestTemplate restTemplate() { 26 | return new RestTemplate(); 27 | } 28 | 29 | @LoadBalanced 30 | @Bean 31 | public AsyncRestTemplate asyncRestTemplate() { 32 | return new AsyncRestTemplate(); 33 | } 34 | 35 | public static void main(String[] args) { 36 | SpringApplication.run(ConsumerApplication.class, args); 37 | } 38 | } 39 | 40 | @RestController 41 | class ServiceInstanceRestController { 42 | @Autowired 43 | private RestTemplate restTemplate; 44 | 45 | @Autowired 46 | private AsyncRestTemplate asyncRestTemplate; 47 | 48 | @Autowired 49 | private ProviderService providerService; 50 | 51 | @RequestMapping("/consumer/restTemplate") 52 | public List demo1() { 53 | List xxx = (List) restTemplate 54 | .getForEntity("http://provider/service-instances/consumer", List.class).getBody(); 55 | return xxx; 56 | } 57 | 58 | @RequestMapping("/consumer/asyncRestTemplate") 59 | public List demo2() { 60 | try { 61 | return (List) asyncRestTemplate 62 | .getForEntity("http://provider/service-instances/consumer", List.class).get().getBody(); 63 | } catch (InterruptedException e) { 64 | e.printStackTrace(); 65 | } catch (ExecutionException e) { 66 | e.printStackTrace(); 67 | } 68 | return null; 69 | } 70 | 71 | @RequestMapping("/consumer/providerService") 72 | public List demo3() { 73 | return providerService.serviceInstancesByApplicationName("consumer"); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /gs-rest-service/complete/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gs-rest-service/initial/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/src/main/java/hello/UserApplication.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.cloud.client.ServiceInstance; 9 | import org.springframework.cloud.client.discovery.DiscoveryClient; 10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 11 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 12 | import org.springframework.cloud.netflix.ribbon.RibbonClient; 13 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 14 | import org.springframework.context.annotation.Bean; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.bind.annotation.RestController; 18 | import org.springframework.web.client.RestTemplate; 19 | 20 | @SpringBootApplication 21 | @RestController 22 | @RibbonClient(name = "say-hello", configuration = SayHelloConfiguration.class) 23 | @EnableDiscoveryClient 24 | @EnableZuulProxy 25 | public class UserApplication { 26 | private RestTemplate nonLoadBalancedRestTemplate = new RestTemplate(); 27 | 28 | @LoadBalanced 29 | @Bean 30 | RestTemplate restTemplate(){ 31 | return new RestTemplate(); 32 | } 33 | 34 | @Autowired 35 | RestTemplate restTemplate; 36 | 37 | @Autowired 38 | private DiscoveryClient discoveryClient; 39 | 40 | @RequestMapping("/hi") 41 | public String hi(@RequestParam(value="name", defaultValue="Artaban") String name) { 42 | List instances = discoveryClient.getInstances("say-hello"); 43 | ServiceInstance instance = instances.get(0); 44 | StringBuilder uri = new StringBuilder(); 45 | if(instance.isSecure()) { 46 | uri.append("https://"); 47 | } else { 48 | uri.append("http://"); 49 | } 50 | 51 | uri.append(instance.getHost()); 52 | uri.append(":"); 53 | uri.append(instance.getPort()); 54 | 55 | String greeting = this.nonLoadBalancedRestTemplate.getForObject(uri + "/greeting", String.class); 56 | return String.format("%s, %s!", greeting, name); 57 | } 58 | 59 | @RequestMapping("/hi2") 60 | public String hi2(@RequestParam(value="name", defaultValue="Artaban") String name) { 61 | String greeting = this.restTemplate.getForObject("http://say-hello/greeting", String.class); 62 | return String.format("%s, %s!", greeting, name); 63 | } 64 | 65 | public static void main(String[] args) { 66 | SpringApplication.run(UserApplication.class, args); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/user/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/say-hello/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/initial/say-hello/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /spring-boot-simple/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 1.4.5.RELEASE 10 | 11 | 12 | com.huawei.cse.sample 13 | spring-boot-simple 14 | 0.0.1-SNAPSHOT 15 | jar 16 | 17 | 18 | 19 | 20 | com.huawei.paas.cse 21 | cse-dependency 22 | 2.3.12 23 | pom 24 | import 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.servicecomb 32 | spring-boot-starter-provider 33 | 34 | 35 | com.huawei.paas.cse 36 | cse-solution-service-engine 37 | 38 | 39 | org.slf4j 40 | slf4j-log4j12 41 | 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter 47 | 48 | 49 | org.hibernate 50 | hibernate-validator 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-compiler-plugin 59 | 60 | 1.8 61 | 1.8 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/say-hello/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | hello 7 | say-hello 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | say-hello 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | 29 | org.apache.servicecomb 30 | java-chassis-dependencies 31 | 1.0.0-m2-SNAPSHOT 32 | pom 33 | import 34 | 35 | 36 | com.huawei.paas.cse 37 | cse-dependency 38 | 2.3.19 39 | pom 40 | import 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-dependencies 45 | Edgware.RELEASE 46 | pom 47 | import 48 | 49 | 50 | 51 | 52 | 53 | com.huawei.paas.cse 54 | cse-solution-spring-cloud 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-starter-web 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-test 68 | test 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-maven-plugin 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 4.0.0 20 | 21 | com.alibaba 22 | dubbo-demo-servicecomb 23 | 2.5.7 24 | 25 | dubbo-demo-consumer-servicecomb 26 | jar 27 | ${project.artifactId} 28 | The demo consumer module of dubbo project 29 | 30 | false 31 | 32 | 33 | 34 | com.alibaba 35 | dubbo-demo-api 36 | ${project.parent.version} 37 | 38 | 39 | 40 | 41 | 42 | maven-dependency-plugin 43 | 44 | 45 | unpack 46 | package 47 | 48 | unpack 49 | 50 | 51 | 52 | 53 | com.alibaba 54 | dubbo 55 | ${project.parent.version} 56 | ${project.build.directory}/dubbo 57 | META-INF/assembly/** 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | maven-assembly-plugin 66 | 67 | src/main/assembly/assembly.xml 68 | 69 | 70 | 71 | make-assembly 72 | package 73 | 74 | single 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /gs-rest-service/complete/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-rest-service 8 | 0.1.0 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 1.5.9.RELEASE 14 | 15 | 16 | 17 | 18 | 19 | 27 | 28 | com.huawei.paas.cse 29 | cse-dependency 30 | 2.3.19 31 | pom 32 | import 33 | 34 | 35 | 36 | 37 | 38 | 39 | com.huawei.paas.cse 40 | cse-solution-spring-cloud 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-web 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-test 49 | test 50 | 51 | 52 | com.jayway.jsonpath 53 | json-path 54 | test 55 | 56 | 57 | 58 | 59 | 1.8 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | 84 | 85 | -------------------------------------------------------------------------------- /gs-rest-service-with-servicecomb/complete/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-rest-service-with-servicecomb 8 | 0.1.0 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 1.5.9.RELEASE 14 | 15 | 16 | 17 | 18 | 19 | 20 | com.huawei.paas.cse 21 | cse-dependency 22 | 2.3.7 23 | pom 24 | import 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.servicecomb 32 | spring-boot-starter-provider 33 | 34 | 35 | com.huawei.paas.cse 36 | cse-solution-service-engine 37 | 38 | 39 | com.huawei.paas.cse 40 | foundation-config-cc 41 | 42 | 43 | com.huawei.paas.cse 44 | foundation-auth 45 | 46 | 47 | org.slf4j 48 | slf4j-log4j12 49 | 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-starter-web 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-test 59 | test 60 | 61 | 62 | com.jayway.jsonpath 63 | json-path 64 | test 65 | 66 | 67 | 68 | 69 | 1.8 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | 94 | 95 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | hello 7 | user 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | user 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | 29 | org.apache.servicecomb 30 | java-chassis-dependencies 31 | 1.0.0-m2-SNAPSHOT 32 | pom 33 | import 34 | 35 | 36 | com.huawei.paas.cse 37 | cse-dependency 38 | 2.3.19 39 | pom 40 | import 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-dependencies 45 | Edgware.RELEASE 46 | pom 47 | import 48 | 49 | 50 | 51 | 52 | 53 | 54 | com.huawei.paas.cse 55 | cse-solution-spring-cloud 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter 60 | 61 | 62 | org.springframework.cloud 63 | spring-cloud-starter-ribbon 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-web 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-starter-test 72 | test 73 | 74 | 75 | 76 | 77 | 78 | 79 | org.springframework.boot 80 | spring-boot-maven-plugin 81 | 82 | 83 | 84 | 85 | 86 | 87 | spring-snapshots 88 | Spring Snapshots 89 | https://repo.spring.io/snapshot 90 | 91 | true 92 | 93 | 94 | 95 | spring-milestones 96 | Spring Milestones 97 | https://repo.spring.io/milestone 98 | 99 | false 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo-servicecomb/dubbo-demo-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 4.0.0 20 | 21 | com.alibaba 22 | dubbo-demo-servicecomb 23 | 2.5.7 24 | 25 | dubbo-demo-provider-servicecomb 26 | jar 27 | ${project.artifactId} 28 | The demo provider module of dubbo project 29 | 30 | false 31 | 32 | 33 | 34 | com.alibaba 35 | dubbo-demo-api 36 | ${project.parent.version} 37 | 38 | 39 | 40 | 41 | 42 | maven-dependency-plugin 43 | 44 | 45 | unpack 46 | package 47 | 48 | unpack 49 | 50 | 51 | 52 | 53 | com.alibaba 54 | dubbo 55 | ${project.parent.version} 56 | ${project.build.directory}/dubbo 57 | META-INF/assembly/** 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | maven-assembly-plugin 66 | 67 | src/main/assembly/assembly.xml 68 | 69 | 70 | 71 | make-assembly 72 | package 73 | 74 | single 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /dubbo-migration/README.md: -------------------------------------------------------------------------------- 1 | 本项目演示了dubbo服务改造为CSE(ServiceComb-java-chassis)服务的主要过程。原始的dubbo DEMO来源于[dubbo官网](https://github.com/alibaba/dubbo/tree/master/dubbo-demo)。目录dubbo-demo是原始的DEMO,dubbo-demo-servicecomb是改造后的DEMO。 2 | 3 | 和本项目类似的项目可以参考:https://github.com/seanyinx/dubbo-to-servicecomb , 从另外一个角度描述了切换过程。读者可以选择参考任何一篇。 4 | 5 | # 如何熟悉改造过程 6 | 1. 建议开发者首先从[dubbo官网](http://dubbo.io/)和[CSE官网](https://java.huaweicse.com/)初步了解两个框架的功能,下载入门指导并了解Provider和Consumer的运行过程。[ServiceComb的开放性设计](https://bbs.huaweicloud.com/blogs/1fc9427c088611e89fc57ca23e93a89f)介绍了CSE的总体设计思路,可以帮助用户做好选型评估。 7 | 2. 改造的主要内容,本质上是改变服务发布方式,开发者需要将使用dubbo发布的RPC接口,使用ServiceComb的RPC方式发布。主要的改造内容是针对服务(注:这里服务指一个进程对外提供的接口。不同的技术发布服务的方式不同。比如Tomcat是符合J2EE标准的容器,采用Servlet来发布服务。由于dubbo和ServiceComb都支持RPC,因此在服务层面的改造比其他技术之间的改造要小很多,当然具体的工作量还可能和开发者写代码的习惯和设计模式有关。),通常涉及到配置文件的修改、增加Annotation描述等,不涉及具体业务逻辑的改造。当然,不同的开发框架可能还提供了一些特定的API接口,这块是改造过程中最不可以预测的部分,也是改造过程中比较难的部分。好在这部分内容很少,对于ServiceComb,开发者多数情况下不会使用任何API接口。不使用框架API接口的好处是切换为其他框架的时候,改造工作量很小。 8 | 3. 我们建议开发者安装Beyond Compare或者其他源码比较工具。了解下面的改造过程从使用比较工具打开dubbo-demo和dubbo-demo-servicecomb开始。 9 | 10 | # 改造过程中涉及的主要部分说明 11 | ## 修改依赖关系。将POM文件中使用dubbo的地方,改为使用CSE组件。(比较pom.xml) 12 | 13 | 开发者可以在dependencyManagement加入下面的配置,这样就可以更好的管理三方件依赖关系。子项目就不需要指定版本号了。dubbo未提供类似的依赖关系机制。 14 | ``` 15 | 16 | 17 | 18 | com.huawei.paas.cse 19 | cse-dependency 20 | 2.3.9 21 | pom 22 | import 23 | 24 | 25 | 26 | ``` 27 | POM文件主要的修改内容涉及到将如下dubbo依赖修改为ServiceComb的依赖: 28 | * dubbo依赖 29 | ``` 30 | 31 | com.alibaba 32 | dubbo 33 | 2.5.7 34 | 35 | ``` 36 | * CSE依赖 37 | ``` 38 | 39 | com.huawei.paas.cse 40 | cse-solution-service-engine 41 | 42 | ``` 43 | ServiceComb提供了非常灵活的可插拔机制。每个组件都可以独立引用使用。为了简化依赖关系配置,这里直接引用了cse-solution-service-engine,它是一个封装好的集合,可以一键式启用CSE提供的服务管控能力。 44 | 45 | 46 | ## 改造服务发布的接口。(比较DemoServiceImpl) 47 | 48 | 在服务接口上使用@RpcSchema(schemaId = "providerSchema")标签,就可以将服务发布为CSE的方式,其中schemaId是本Provider唯一的契约标识,CSE会给服务自动生成契约,使用者可以通过契约的内容,使用浏览器或者CSE提供的客户端来访问。在dubbo的原始DEMO中,服务发布是通过dubbo-demo-provider.xml来定义的。dubbo的RPC接口没有契约,并且无法通过HTTP协议进行访问。加上标签后,可以删除dubbo-demo-provider.xml里面发布服务相关的内容。 49 | 50 | ## 改造客户端引用(比较Consumer.java) 51 | 52 | 在服务接口上使用@RpcReference(microserviceName="provider", schemaId="providerSchema")标签,就可以获取远程接口的引用,其中microserviceName就是Provider的微服务名,schemaId就是Provider发布的契约。在dubbo的原始DEMO中,远程引用是通过ubbo-demo-consumer.xml来定义的,并且通过DemoService demoService = (DemoService) context.getBean("demoService");来获取引用。 53 | 54 | 55 | ## 定义微服务信息。(增加microservice.yaml文件) 56 | 57 | 这个文件是本项目的元数据信息。定义了应用名称、微服务名称、本服务监听的IP和端口等信息。dubbo服务监听的信息也在dubbo-demo-provider.xml定义。增加这个文件后,可以删除dubbo相关信息。 58 | 59 | 60 | ## 修改Main,启动服务(比较Provider.java和Consumer.java) 61 | 62 | dubbo和ServiceComb类似,都是基于Spring来启动的。ServiceComb提供了Log4jUtils和BeanUtils来简化Log4j的初始化和Spring的初始化。Log4jUtils.init方法,会默认合并所有的classpath*:config/log4j.properties文件;BeanUtils.init默认会加载所有的classpath*:META-INF/spring/*.bean.xml文件。dubbo加载的路径是在代码中指定的:new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-consumer.xml"})。 63 | 64 | ## 结束 65 | 经过以上的步骤,dubbo DEMO改造为ServiceComb的工作就完成了。正如我们说的,改造的主要部分在于“重新定义服务发布的方式”。 为了让改造后的项目更加简化,我们删除了dubbo不在使用的dubbo-demo-provider.xml和dubbo-demo-consumer.xml,并且增加了demo.bean.xml,该文件起到告知spring加载标签定义的Bean的作用。这样我们可以使用标签来定义Bean,是代码看起来更加简洁。运行原始的dubbo服务和改造后的服务,都会在日志里面输出大家熟悉的"Hello world"。在运行改造后的ServiceComb前,需要[下载](https://console.huaweicloud.com/cse/?region=cn-north-1#/cse/tools)一个服务中心在本地,并运行。 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 4.0.0 19 | 20 | com.alibaba 21 | dubbo-demo 22 | 2.5.7 23 | 24 | dubbo-demo-consumer 25 | jar 26 | ${project.artifactId} 27 | The demo consumer module of dubbo project 28 | 29 | false 30 | 31 | 32 | 33 | com.alibaba 34 | dubbo-demo-api 35 | ${project.parent.version} 36 | 37 | 38 | com.alibaba 39 | dubbo 40 | 2.5.7 41 | 42 | 43 | 44 | 45 | 46 | maven-dependency-plugin 47 | 48 | 49 | unpack 50 | package 51 | 52 | unpack 53 | 54 | 55 | 56 | 57 | com.alibaba 58 | dubbo 59 | ${project.parent.version} 60 | ${project.build.directory}/dubbo 61 | META-INF/assembly/** 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | maven-assembly-plugin 70 | 71 | src/main/assembly/assembly.xml 72 | 73 | 74 | 75 | make-assembly 76 | package 77 | 78 | single 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /dubbo-migration/dubbo-demo/dubbo-demo-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 4.0.0 19 | 20 | com.alibaba 21 | dubbo-demo 22 | 2.5.7 23 | 24 | dubbo-demo-provider 25 | jar 26 | ${project.artifactId} 27 | The demo provider module of dubbo project 28 | 29 | false 30 | 31 | 32 | 33 | com.alibaba 34 | dubbo-demo-api 35 | ${project.parent.version} 36 | 37 | 38 | com.alibaba 39 | dubbo 40 | 2.5.7 41 | 42 | 43 | 44 | 45 | 46 | maven-dependency-plugin 47 | 48 | 49 | unpack 50 | package 51 | 52 | unpack 53 | 54 | 55 | 56 | 57 | com.alibaba 58 | dubbo 59 | ${project.parent.version} 60 | ${project.build.directory}/dubbo 61 | META-INF/assembly/** 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | maven-assembly-plugin 70 | 71 | src/main/assembly/assembly.xml 72 | 73 | 74 | 75 | make-assembly 76 | package 77 | 78 | single 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /gs-client-side-load-balancing/complete/user/src/test/java/hello/UserApplicationTests.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.SpringApplication; 11 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 12 | import org.springframework.boot.context.embedded.LocalServerPort; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.boot.test.web.client.TestRestTemplate; 15 | import org.springframework.context.ConfigurableApplicationContext; 16 | import org.springframework.context.annotation.Configuration; 17 | import org.springframework.http.HttpStatus; 18 | import org.springframework.http.ResponseEntity; 19 | import org.springframework.test.context.junit4.SpringRunner; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RestController; 22 | 23 | import static org.assertj.core.api.BDDAssertions.then; 24 | 25 | /** 26 | * @author Marcin Grzejszczak 27 | */ 28 | @RunWith(SpringRunner.class) 29 | @SpringBootTest(classes = UserApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 30 | public class UserApplicationTests { 31 | 32 | ConfigurableApplicationContext application1; 33 | ConfigurableApplicationContext application2; 34 | ConfigurableApplicationContext application3; 35 | 36 | @Before 37 | public void startApps() { 38 | this.application1 = startApp(8090); 39 | this.application2 = startApp(9092); 40 | this.application3 = startApp(9999); 41 | } 42 | 43 | @After 44 | public void closeApps() { 45 | this.application1.close(); 46 | this.application2.close(); 47 | this.application3.close(); 48 | } 49 | 50 | @LocalServerPort 51 | private int port; 52 | 53 | @Autowired 54 | private TestRestTemplate testRestTemplate; 55 | 56 | @Test 57 | public void shouldRoundRobinOverInstancesWhenCallingServicesViaRibbon() throws InterruptedException { 58 | ResponseEntity response1 = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/hi?name=foo", String.class); 59 | ResponseEntity response2 = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/hi?name=foo", String.class); 60 | ResponseEntity response3 = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/hi?name=foo", String.class); 61 | 62 | then(response1.getStatusCode()).isEqualTo(HttpStatus.OK); 63 | then(response1.getBody()).isEqualTo("1, foo!"); 64 | then(response2.getStatusCode()).isEqualTo(HttpStatus.OK); 65 | then(response2.getBody()).isEqualTo("2, foo!"); 66 | then(response3.getStatusCode()).isEqualTo(HttpStatus.OK); 67 | then(response3.getBody()).isEqualTo("3, foo!"); 68 | } 69 | 70 | private ConfigurableApplicationContext startApp(int port) { 71 | return SpringApplication.run(TestApplication.class, 72 | "--server.port=" + port, 73 | "--spring.jmx.enabled=false"); 74 | } 75 | 76 | @Configuration 77 | @EnableAutoConfiguration 78 | @RestController 79 | static class TestApplication { 80 | 81 | static AtomicInteger atomicInteger = new AtomicInteger(); 82 | 83 | @RequestMapping(value = "/greeting") 84 | public Integer greet() { 85 | return atomicInteger.incrementAndGet(); 86 | } 87 | 88 | @RequestMapping(value = "/") 89 | public String health() { 90 | return "ok"; 91 | } 92 | } 93 | } 94 | --------------------------------------------------------------------------------