├── 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