├── .gitignore ├── HouseAppWithSpringBoot2 ├── .gitignore ├── README.md ├── account-service │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── houseapp │ │ │ └── account │ │ │ ├── AccountApplication.java │ │ │ ├── dao │ │ │ ├── AccountInfo.java │ │ │ ├── AccountMapper.java │ │ │ └── MockedAccountMapper.java │ │ │ └── service │ │ │ ├── AccountEndpointImpl.java │ │ │ └── AccountService.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── spring │ │ │ └── account.bean.xml │ │ ├── application.yml │ │ ├── config │ │ ├── AccountMapper.xml │ │ └── mybatis-config.xml │ │ └── dbcp.properties ├── build-deploy-run.md ├── build-images.sh ├── common │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── houseapp │ │ │ ├── account │ │ │ └── api │ │ │ │ └── AccountEndpoint.java │ │ │ ├── customer │ │ │ └── api │ │ │ │ └── CustomerEndpoint.java │ │ │ ├── product │ │ │ └── api │ │ │ │ ├── ProductEndpoint.java │ │ │ │ └── ProductInfo.java │ │ │ └── user │ │ │ └── api │ │ │ ├── UserEndpoint.java │ │ │ └── UserInfo.java │ │ └── resources │ │ └── microservice.yaml ├── customer-service │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── houseapp │ │ │ └── customer │ │ │ ├── CustomerApplication.java │ │ │ └── service │ │ │ ├── ConfigurationPropertiesModel.java │ │ │ ├── CustomerEndpointImpl.java │ │ │ └── CustomerService.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── spring │ │ │ └── customer.bean.xml │ │ └── application.yml ├── customer-website │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── houseapp │ │ │ └── website │ │ │ └── WebsiteApplication.java │ │ └── resources │ │ ├── application.yml │ │ └── static │ │ ├── WEB-INF │ │ └── web.xml │ │ ├── checkout.html │ │ ├── css │ │ ├── bootstrap.css │ │ ├── flexslider.css │ │ ├── font-awesome.css │ │ ├── highlight.css │ │ ├── list.css │ │ ├── main.css │ │ ├── market.css │ │ └── style.css │ │ ├── dist │ │ ├── css │ │ │ ├── bootstrap2 │ │ │ │ ├── bootstrap-switch.css │ │ │ │ └── bootstrap-switch.min.css │ │ │ └── bootstrap3 │ │ │ │ ├── bootstrap-switch.css │ │ │ │ └── bootstrap-switch.min.css │ │ └── js │ │ │ ├── bootstrap-switch.js │ │ │ └── bootstrap-switch.min.js │ │ ├── examples.html │ │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── images │ │ ├── 1489246971535.jpg │ │ ├── 1493696851151.png │ │ ├── 1496214523346.jpg │ │ ├── 1496236247761.png │ │ ├── 2017091022471293.jpg │ │ ├── 20170911192746247 (1).jpg │ │ ├── 20170911192746247.jpg │ │ ├── 20170914182855928.jpg │ │ ├── 428_428_1477897959639mp.jpg │ │ ├── 428_428_1490921883474mp.jpg │ │ ├── 428_428_1494902274982mp.jpg │ │ ├── 428_428_1500629825123mp.jpg │ │ ├── 428_428_1503399072486mp.jpg │ │ ├── 428_428_1503976624403mp.jpg │ │ ├── 428_428_1504595886092mp.jpg │ │ ├── 428_428_1504748150715mp.jpg │ │ ├── 428_428_1504748540340mp.jpg │ │ ├── 428_428_1504837511355mp.jpg │ │ ├── apple-1485458_960_720.png │ │ ├── arrow.png │ │ ├── card.png │ │ ├── cart.png │ │ ├── cherries-1991042_960_720.png │ │ ├── edit.png │ │ ├── grapes-1990789_960_720.png │ │ ├── huxingtu1.jpg │ │ ├── huxingtu2.jpg │ │ ├── huxingtu3.jpg │ │ ├── huxingtu4.jpg │ │ ├── img-sp.png │ │ ├── lemons-2035490_960_720.png │ │ ├── logout_16px_27579_easyicon.net.png │ │ ├── offer.png │ │ ├── pears-1990797_960_720.png │ │ ├── settings_16.832px_1182692_easyicon.net.png │ │ ├── shopping_cart_16px_1093629_easyicon.net.png │ │ ├── shopping_cart_empty_16px_1117680_easyicon.net.png │ │ ├── star.png │ │ ├── star1.png │ │ ├── strawberry-1485456_960_720.png │ │ ├── tag.png │ │ ├── user_13.394714407502px_1206721_easyicon.net.png │ │ └── 下载.jpg │ │ ├── index.html │ │ ├── index_index.html │ │ ├── js │ │ ├── bootstrap.min.js │ │ ├── counterup.min.js │ │ ├── easing.js │ │ ├── highlight.js │ │ ├── jquery-1.11.1.min.js │ │ ├── jquery.flexslider.js │ │ ├── jquery.wmuSlider.js │ │ ├── main.js │ │ ├── minicart.js │ │ ├── minicart.min.js │ │ ├── move-top.js │ │ ├── okzoom.js │ │ └── waypoints.min.js │ │ ├── list.html │ │ ├── login.html │ │ ├── market.html │ │ └── toastr │ │ ├── helium.js │ │ ├── toastr.css │ │ └── toastr.js ├── deployment │ ├── blueprint │ │ ├── blueprint.yaml │ │ └── house-appconfig.json │ └── configmap-templates │ │ ├── cse-credentials.yaml │ │ ├── mysql-accountdb.yaml │ │ ├── mysql-productdb.yaml │ │ ├── mysql-userdb.yaml │ │ └── redis-credential.yaml ├── devcloud │ └── README.md ├── docs │ ├── compile_and_run.md │ ├── images │ │ ├── system-components.JPG │ │ └── ui.png │ └── microservice_technology_introduction.md ├── edge-service │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── houseapp │ │ │ └── edge │ │ │ ├── ApiDispatcher.java │ │ │ ├── AuthFilter.java │ │ │ ├── EdgeApplication.java │ │ │ ├── LoginDispatcher.java │ │ │ ├── RedirectToLoginDispatcher.java │ │ │ └── WebPageDispatcher.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── services │ │ │ ├── org.apache.servicecomb.common.rest.filter.HttpServerFilter │ │ │ └── org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher │ │ └── application.yml ├── init-db │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── resources │ │ ├── Dockerfile │ │ ├── entrypoint.sh │ │ └── sql │ │ ├── clear.sql │ │ ├── create_db_account.sql │ │ ├── create_db_product.sql │ │ └── create_db_user.sql ├── loadtestclient │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── houseapp │ │ │ └── loadtest │ │ │ ├── LoadApplication.java │ │ │ └── LoadTestEndpoint.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── spring │ │ │ └── load.bean.xml │ │ └── application.yml ├── pom.xml ├── product-service │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── houseapp │ │ │ └── product │ │ │ ├── ProductApplication.java │ │ │ ├── dao │ │ │ ├── MockedProductMapper.java │ │ │ └── ProductMapper.java │ │ │ └── service │ │ │ ├── ProductEndpointImpl.java │ │ │ └── ProductService.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── spring │ │ │ └── product.bean.xml │ │ ├── application.yml │ │ ├── config │ │ ├── ProductMapper.xml │ │ └── mybatis-config.xml │ │ └── dbcp.properties ├── settings.xml ├── start.bat └── user-service │ ├── .gitignore │ ├── Dockerfile │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── huawei │ │ └── cse │ │ └── houseapp │ │ └── user │ │ ├── UserApplication.java │ │ ├── dao │ │ ├── MockedUserMapper.java │ │ └── UserMapper.java │ │ └── service │ │ ├── UserEndpointImpl.java │ │ └── UserService.java │ └── resources │ ├── Dockerfile │ ├── META-INF │ └── spring │ │ └── user.bean.xml │ ├── application.yml │ ├── config │ ├── UserMapper.xml │ └── mybatis-config.xml │ └── dbcp.properties ├── README.md ├── cse-codegen-demo ├── consumer │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── paas │ │ │ └── consumer │ │ │ └── ConsumerApplication.java │ │ └── resources │ │ ├── META-INF.spring │ │ └── cse.consumer.bean.xml │ │ └── microservice.yaml ├── pom.xml └── provider │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── huawei │ │ └── paas │ │ └── provider │ │ └── ProviderApplication.java │ └── resources │ ├── META-INF.spring │ └── cse.consumer.bean.xml │ └── microservice.yaml ├── cse-codegen-doc ├── clone.png ├── consumer.png ├── consumerExtra.png ├── consumerShow.png ├── delete.png ├── generate.png ├── gitRepoConsumer.png ├── gitRepoProvider.png ├── provider.png ├── serviceCenter.png ├── serviceCenterConsumer.png ├── serviceCenterDownload.png ├── yamlConsumer.png ├── yamlProvider.png ├── 使用CSE-Codegen插件快速开发微服务.md └── 使用CSE-Codegen插件快速开发微服务.pdf ├── isolation-performance ├── user-service-a │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── user │ │ │ ├── Server.java │ │ │ ├── dao │ │ │ ├── SessionInfo.java │ │ │ ├── SessionMapper.java │ │ │ ├── UserInfo.java │ │ │ └── UserMapper.java │ │ │ └── endpoint │ │ │ ├── TimeoutEndpoint.java │ │ │ ├── UserInfoView.java │ │ │ └── UserServiceEndpoint.java │ │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ └── user.bean.xml │ │ ├── config │ │ ├── SessionMapper.xml │ │ ├── UserMapper.xml │ │ ├── create_db_user.sql │ │ └── mybatis-config.xml │ │ └── microservice.yaml ├── user-service-c │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── user │ │ │ ├── PerfClient.java │ │ │ ├── dao │ │ │ ├── SessionInfo.java │ │ │ ├── SessionMapper.java │ │ │ ├── UserInfo.java │ │ │ └── UserMapper.java │ │ │ └── endpoint │ │ │ ├── TimeoutEndpoint.java │ │ │ ├── UserInfoView.java │ │ │ └── UserServiceEndpoint.java │ │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ └── user.bean.xml │ │ ├── config │ │ ├── SessionMapper.xml │ │ ├── UserMapper.xml │ │ ├── create_db_user.sql │ │ └── mybatis-config.xml │ │ └── microservice.yaml └── user-service │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── huawei │ │ └── cse │ │ └── porter │ │ └── user │ │ ├── Client.java │ │ ├── dao │ │ ├── SessionInfo.java │ │ ├── SessionMapper.java │ │ ├── UserInfo.java │ │ └── UserMapper.java │ │ └── endpoint │ │ ├── TimeoutEndpoint.java │ │ ├── UserInfoView.java │ │ └── UserServiceEndpoint.java │ └── resources │ ├── META-INF │ └── spring │ │ └── user.bean.xml │ ├── config │ ├── SessionMapper.xml │ ├── UserMapper.xml │ ├── create_db_user.sql │ └── mybatis-config.xml │ └── microservice.yaml ├── multi-framework ├── README.md ├── auth │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ ├── AuthMain.java │ │ │ ├── CustomerAccessTokenConverter.java │ │ │ ├── OAuth2ServerConfig.java │ │ │ └── SecurityConfiguration.java │ │ └── resources │ │ └── application.yml ├── gateway-service │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ ├── DefaultCseDispatcher.java │ │ │ ├── GatewayMain.java │ │ │ ├── GenericHttpDispatcher.java │ │ │ └── GenericHttpWithDiscoveryDispatcher.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── services │ │ │ └── org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher │ │ └── microservice.yaml ├── store │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ ├── AuthService.java │ │ │ ├── StoreEndpoint.java │ │ │ ├── StoreMain.java │ │ │ ├── ThirdPartyRegistry.java │ │ │ └── Token.java │ │ └── resources │ │ └── application.yml └── user │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── huawei │ │ └── cse │ │ └── porter │ │ └── oauth2 │ │ ├── UserEndpoint.java │ │ └── UserMain.java │ └── resources │ └── application.yml ├── porter ├── README.md ├── porter_lightweight │ ├── README.md │ ├── common │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── huawei │ │ │ │ └── cse │ │ │ │ └── porter │ │ │ │ ├── file │ │ │ │ └── api │ │ │ │ │ ├── FileEndpoint.java │ │ │ │ │ └── FileService.java │ │ │ │ └── user │ │ │ │ └── api │ │ │ │ ├── SessionInfo.java │ │ │ │ ├── UserEndpoint.java │ │ │ │ └── UserService.java │ │ │ └── resources │ │ │ └── microservice.yaml │ ├── file-service │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── huawei │ │ │ │ └── cse │ │ │ │ └── porter │ │ │ │ └── file │ │ │ │ ├── FileMain.java │ │ │ │ └── service │ │ │ │ ├── FileServiceImpl.java │ │ │ │ ├── FileStoreService.java │ │ │ │ ├── LocalFileStoreService.java │ │ │ │ └── SessionInfo.java │ │ │ └── resources │ │ │ ├── Dockerfile │ │ │ ├── META-INF │ │ │ └── spring │ │ │ │ └── file.bean.xml │ │ │ ├── microservice.yaml │ │ │ └── upload.html │ ├── gateway-service │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── huawei │ │ │ │ └── cse │ │ │ │ └── porter │ │ │ │ └── gateway │ │ │ │ ├── ApiDispatcher.java │ │ │ │ ├── AuthHandler.java │ │ │ │ ├── EdgeSSLCustom.java │ │ │ │ ├── GatewayMain.java │ │ │ │ └── StaticWebpageDispatcher.java │ │ │ └── resources │ │ │ ├── Dockerfile │ │ │ ├── META-INF │ │ │ └── services │ │ │ │ └── org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher │ │ │ ├── config │ │ │ └── cse.handler.xml │ │ │ ├── microservice.yaml │ │ │ ├── server.p12 │ │ │ ├── trust.jks │ │ │ └── ui │ │ │ ├── css │ │ │ └── style.css │ │ │ ├── js │ │ │ ├── jquery-1.11.1.min.js │ │ │ ├── login.js │ │ │ └── upload.js │ │ │ ├── login.html │ │ │ └── upload.html │ ├── pom.xml │ └── user-service │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── user │ │ │ ├── UserMain.java │ │ │ ├── dao │ │ │ ├── SessionInfoModel.java │ │ │ ├── SessionMapper.java │ │ │ ├── UserInfo.java │ │ │ └── UserMapper.java │ │ │ └── service │ │ │ └── UserServiceImpl.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── spring │ │ │ └── user.bean.xml │ │ ├── config │ │ ├── SessionMapper.xml │ │ ├── UserMapper.xml │ │ ├── create_db_user.sql │ │ └── mybatis-config.xml │ │ └── microservice.yaml └── porter_springboot2 │ ├── README.md │ ├── common │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ ├── file │ │ │ └── api │ │ │ │ ├── FileEndpoint.java │ │ │ │ └── FileService.java │ │ │ └── user │ │ │ └── api │ │ │ ├── SessionInfo.java │ │ │ ├── UserEndpoint.java │ │ │ └── UserService.java │ │ └── resources │ │ └── microservice.yaml │ ├── file-service │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── file │ │ │ ├── FileMain.java │ │ │ └── service │ │ │ ├── FileServiceImpl.java │ │ │ ├── FileStoreService.java │ │ │ ├── LocalFileStoreService.java │ │ │ └── SessionInfo.java │ │ └── resources │ │ ├── application.yaml │ │ └── upload.html │ ├── gateway-service │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── gateway │ │ │ ├── ApiDispatcher.java │ │ │ ├── AuthHandler.java │ │ │ ├── EdgeSSLCustom.java │ │ │ ├── GatewayMain.java │ │ │ ├── Session.java │ │ │ └── StaticWebpageDispatcher.java │ │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher │ │ ├── application.yaml │ │ ├── config │ │ └── cse.handler.xml │ │ ├── server.p12 │ │ ├── trust.jks │ │ └── ui │ │ ├── css │ │ └── style.css │ │ ├── js │ │ ├── jquery-1.11.1.min.js │ │ ├── login.js │ │ └── upload.js │ │ ├── login.html │ │ └── upload.html │ ├── pom.xml │ └── user-service │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── huawei │ │ └── cse │ │ └── porter │ │ └── user │ │ ├── UserMain.java │ │ ├── dao │ │ ├── SessionEntity.java │ │ ├── SessionRepository.java │ │ ├── UserEntity.java │ │ └── UserRepository.java │ │ └── service │ │ └── UserServiceImpl.java │ └── resources │ ├── application.yml │ └── config │ └── create_db_user.sql ├── springboot-oauth2-sample ├── README.md ├── cse-oauth2-resource-server │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── oauth2 │ │ │ ├── AccessDeniedExceptionConverter.java │ │ │ ├── CustomTokenEnhancer.java │ │ │ ├── CustomerAccessTokenConverter.java │ │ │ ├── OAuth2ResourceServerMain.java │ │ │ ├── OAuth2ServerConfig.java │ │ │ ├── SecurityConfiguration.java │ │ │ └── TestEndpoint.java │ │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter │ │ └── application.yml ├── gateway-service │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── gateway │ │ │ ├── GatewayMain.java │ │ │ └── GenericHttpDispatcher.java │ │ └── resources │ │ ├── Dockerfile │ │ ├── META-INF │ │ └── services │ │ │ └── org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher │ │ └── microservice.yaml ├── springboot2-oauth2-resource-server │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── cse │ │ │ └── porter │ │ │ └── oauth2 │ │ │ ├── CustomTokenEnhancer.java │ │ │ ├── CustomerAccessTokenConverter.java │ │ │ ├── OAuth2ResourceServerMain.java │ │ │ ├── OAuth2ServerConfig.java │ │ │ ├── SecurityConfiguration.java │ │ │ └── TestEndpoint.java │ │ └── resources │ │ └── application.yml └── springboot2-oauth2-server │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── huawei │ │ └── cse │ │ └── porter │ │ └── oauth2 │ │ ├── CustomerAccessTokenConverter.java │ │ ├── OAuth2ServerConfig.java │ │ ├── OAuth2ServerMain.java │ │ └── SecurityConfiguration.java │ └── resources │ └── application.yml ├── springboot-sample ├── spingboot2-sample-zuul │ ├── bussiness │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── provider │ │ │ │ ├── BusinessService.java │ │ │ │ ├── IBusinessService.java │ │ │ │ └── ServerMain.java │ │ │ └── resources │ │ │ └── application.yml │ └── gateway │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── io │ │ │ └── provider │ │ │ ├── GatewayMain.java │ │ │ └── IBusinessService.java │ │ └── resources │ │ └── application.yml └── springboot1-sample-security │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── io │ │ └── provider │ │ ├── AccessDeniedService.java │ │ ├── BusinessService.java │ │ ├── DeniedInfo.java │ │ ├── Hello.java │ │ ├── HelloService.java │ │ └── ServerMain.java │ └── resources │ ├── META-INF │ └── spring │ │ └── cse.bean.xml │ └── application.yml ├── springcloud-sample-cse-access ├── README.md ├── pom.xml ├── settings.xml ├── springcloud-consumer │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── consumer │ │ │ │ ├── ClientMain.java │ │ │ │ ├── Hello.java │ │ │ │ └── HelloService.java │ │ │ └── resources │ │ │ └── application.yml │ └── start.sh └── springcloud-provider │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── pom.xml │ ├── src │ └── main │ │ ├── java │ │ └── io │ │ │ └── provider │ │ │ ├── Hello.java │ │ │ ├── HelloService.java │ │ │ └── ServerMain.java │ │ └── resources │ │ └── application.yml │ └── start.sh ├── springcloud-sample-cse-edge ├── README.md ├── edge-service │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── provider │ │ │ │ └── EdgeMain.java │ │ │ └── resources │ │ │ └── application.yml │ └── start.sh ├── performance-client │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── provider │ │ │ │ ├── Hello.java │ │ │ │ └── PerformanceMain.java │ │ │ └── resources │ │ │ └── application.yml │ └── start.sh ├── pom.xml ├── settings.xml ├── springcloud-consumer │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── consumer │ │ │ │ ├── ClientMain.java │ │ │ │ ├── Configuration.java │ │ │ │ ├── ConsumerHelloService.java │ │ │ │ └── Hello.java │ │ │ └── resources │ │ │ └── application.yml │ └── start.sh └── springcloud-provider │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── pom.xml │ ├── src │ └── main │ │ ├── java │ │ └── io │ │ │ └── provider │ │ │ ├── Hello.java │ │ │ ├── HelloService.java │ │ │ └── ServerMain.java │ │ └── resources │ │ └── application.yml │ └── start.sh ├── springcloud-sample-cse-rpc ├── README.md ├── pom.xml ├── settings.xml ├── springcloud-consumer │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── io │ │ │ │ └── consumer │ │ │ │ ├── ClientMain.java │ │ │ │ ├── Configuration.java │ │ │ │ ├── ConsumerHelloService.java │ │ │ │ └── Hello.java │ │ │ └── resources │ │ │ └── application.yml │ └── start.sh └── springcloud-provider │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── pom.xml │ ├── src │ └── main │ │ ├── java │ │ └── io │ │ │ └── provider │ │ │ ├── Hello.java │ │ │ ├── HelloService.java │ │ │ └── ServerMain.java │ │ └── resources │ │ └── application.yml │ └── start.sh └── springcloud-sample ├── README.md ├── eureka-server ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── io │ │ └── eureka │ │ └── EurekaServer.java │ └── resources │ └── application.properties ├── pom.xml ├── springcloud-consumer ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── io │ │ └── consumer │ │ ├── ClientMain.java │ │ ├── Hello.java │ │ └── HelloService.java │ └── resources │ └── application.yml └── springcloud-provider ├── .gitignore ├── pom.xml └── src └── main ├── java └── io │ └── provider │ ├── Hello.java │ ├── HelloService.java │ └── ServerMain.java └── resources └── application.yml /.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 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/.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 | 84 | # gradle 85 | .gradle 86 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/README.md: -------------------------------------------------------------------------------- 1 | # 抢购系统 2 | 3 | ## 微服务组成图例 4 | ![](docs/images/system-components.JPG) 5 | 6 | ## [微服务技术选型介绍](docs/microservice_technology_introduction.md) 7 | 8 | ## [编译运行](docs/compile_and_run.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/java/com/huawei/cse/houseapp/account/AccountApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.account; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class AccountApplication { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(AccountApplication.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/java/com/huawei/cse/houseapp/account/dao/AccountInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.account.dao; 2 | 3 | public class AccountInfo { 4 | private long userId; 5 | private double totalBalance; 6 | private boolean reserved; 7 | 8 | public long getUserId() { 9 | return userId; 10 | } 11 | public void setUserId(long userId) { 12 | this.userId = userId; 13 | } 14 | public double getTotalBalance() { 15 | return totalBalance; 16 | } 17 | public void setTotalBalance(double totalBalance) { 18 | this.totalBalance = totalBalance; 19 | } 20 | public boolean isReserved() { 21 | return reserved; 22 | } 23 | public void setReserved(boolean reserved) { 24 | this.reserved = reserved; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/java/com/huawei/cse/houseapp/account/dao/AccountMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.account.dao; 2 | 3 | public interface AccountMapper { 4 | AccountInfo getAccountInfo(long userId); 5 | 6 | void updateAccountInfo(AccountInfo info); 7 | 8 | void createAccountInfo(AccountInfo info); 9 | 10 | void clear(); 11 | 12 | Double queryReduced(); 13 | } 14 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/java/com/huawei/cse/houseapp/account/dao/MockedAccountMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.account.dao; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class MockedAccountMapper implements AccountMapper { 7 | Map accounts = new HashMap<>(); 8 | 9 | public MockedAccountMapper() { 10 | } 11 | 12 | @Override 13 | public AccountInfo getAccountInfo(long userId) { 14 | return accounts.get(userId); 15 | } 16 | 17 | @Override 18 | public void updateAccountInfo(AccountInfo info) { 19 | 20 | } 21 | 22 | @Override 23 | public void createAccountInfo(AccountInfo info) { 24 | accounts.putIfAbsent(info.getUserId(), info); 25 | } 26 | 27 | @Override 28 | public void clear() { 29 | accounts.clear(); 30 | } 31 | 32 | @Override 33 | public Double queryReduced() { 34 | double remain = 0; 35 | for(AccountInfo i : accounts.values()) { 36 | remain = remain + i.getTotalBalance(); 37 | } 38 | return accounts.size() * 8000000D - remain; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | COPY ./account-service/target/account-service-0.0.1-SNAPSHOT.jar /home/apps/server 4 | COPY ./account-service/target/lib/ /home/apps/server/lib 5 | ENTRYPOINT ["java", "-Ddb.url=jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}", "-Ddb.username=${DB_USERNAME}", "-Ddb.password=${DB_PASSWD}", "-Dcse.tcc.transaction.redis.host=${TCC_REDIS_HOST}", "-Dcse.tcc.transaction.redis.port=${TCC_REDIS_PORT}", "-Dcse.tcc.transaction.redis.password=${TCC_REDIS_PASSWD}", "-jar", "/home/apps/server/account-service-0.0.1-SNAPSHOT.jar"] 6 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | ## Spring Boot configurations 4 | spring: 5 | application: 6 | name: account-service 7 | main: 8 | allow-bean-definition-overriding: true 9 | server: 10 | port: 8094 11 | 12 | ## spring mvc rest servlet path 13 | servlet: 14 | path: /mvc 15 | 16 | ## CSE configurations 17 | cse: 18 | rest: 19 | address: 0.0.0.0:8094 20 | 21 | ## cse rest servlet path 22 | servlet: 23 | urlPattern: /* 24 | 25 | # alpha 26 | alpha: 27 | cluster: 28 | address: 127.0.0.1:7080 29 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/account-service/src/main/resources/dbcp.properties: -------------------------------------------------------------------------------- 1 | db.url=jdbc:mysql://localhost/account_db?useSSL=false 2 | db.driver=com.mysql.jdbc.Driver 3 | db.username=root 4 | db.password=root -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | com.huawei.cse.houseapp 21 | houseapp 22 | 0.0.1-SNAPSHOT 23 | 24 | 4.0.0 25 | 26 | common 27 | 28 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/src/main/java/com/huawei/cse/houseapp/account/api/AccountEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.account.api; 2 | 3 | public interface AccountEndpoint { 4 | boolean payWithTransactionSaga(long userid, double amount); 5 | 6 | boolean payWithTransactionTCC(long userid, double amount); 7 | 8 | boolean payWithoutTransaction(long userid, double amount); 9 | 10 | long login(String userName, String password); 11 | 12 | double queryReduced(); 13 | } 14 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/src/main/java/com/huawei/cse/houseapp/customer/api/CustomerEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.customer.api; 2 | 3 | import java.util.List; 4 | 5 | import com.huawei.cse.houseapp.product.api.ProductInfo; 6 | 7 | public interface CustomerEndpoint { 8 | boolean buyWithTransactionSaga(long userId, long productId, double price); 9 | 10 | boolean buyWithTransactionTCC(long userId, long productId, double price); 11 | 12 | boolean buyWithoutTransaction(long userId, long productId, double price); 13 | 14 | long login(String user, String password); 15 | 16 | String balance(); 17 | 18 | public List searchAllProducts(); 19 | } 20 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/src/main/java/com/huawei/cse/houseapp/product/api/ProductEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.product.api; 2 | 3 | import java.util.List; 4 | 5 | public interface ProductEndpoint { 6 | List searchAll(int userId); 7 | 8 | public List searchAllForCustomer(); 9 | 10 | void addProduct(double price); 11 | 12 | public boolean buyWithTransactionSaga(long productId, long userId, double price); 13 | 14 | public boolean buyWithTransactionTCC(long productId, long userId, double price); 15 | 16 | public boolean buyWithoutTransaction(long productId, long userId, double price); 17 | 18 | long login(String userName, String password); 19 | 20 | double queryReduced(); 21 | } 22 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/src/main/java/com/huawei/cse/houseapp/user/api/UserEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.user.api; 2 | 3 | public interface UserEndpoint { 4 | long login2(String userName, String password); 5 | 6 | long login(String userName, String password); 7 | 8 | boolean buyWithTransactionSaga(long userId, double price); 9 | 10 | boolean buyWithTransactionTCC(long userId, double price); 11 | 12 | boolean buyWithoutTransaction(long userId, double price); 13 | 14 | double queryReduced(); 15 | 16 | UserInfo getUserInfo(String userName); 17 | } 18 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/src/main/java/com/huawei/cse/houseapp/user/api/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.user.api; 2 | 3 | public class UserInfo { 4 | private long userId; 5 | 6 | private String userName; 7 | 8 | private double totalBalance; 9 | 10 | private boolean reserved; 11 | 12 | public long getUserId() { 13 | return userId; 14 | } 15 | 16 | public void setUserId(long userId) { 17 | this.userId = userId; 18 | } 19 | 20 | public String getUserName() { 21 | return userName; 22 | } 23 | 24 | public void setUserName(String userName) { 25 | this.userName = userName; 26 | } 27 | 28 | public double getTotalBalance() { 29 | return totalBalance; 30 | } 31 | 32 | public void setTotalBalance(double totalBalance) { 33 | this.totalBalance = totalBalance; 34 | } 35 | 36 | public boolean isReserved() { 37 | return reserved; 38 | } 39 | 40 | public void setReserved(boolean reserved) { 41 | this.reserved = reserved; 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/common/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 10 2 | 3 | ## CSE configurations 4 | 5 | APPLICATION_ID: houseapp 6 | service_description: 7 | name: ${spring.application.name} 8 | version: 0.0.1 9 | 10 | cse: 11 | test: 12 | house: 13 | yamlValue: xyz 14 | yamlValueOverride: abc 15 | service: 16 | registry: 17 | address: https://cse.cn-north-1.myhuaweicloud.com 18 | instance: 19 | watch: false 20 | config: 21 | client: 22 | serverUri: https://cse.cn-north-1.myhuaweicloud.com 23 | refreshMode: 1 24 | refresh_interval: 5000 25 | monitor: 26 | client: 27 | serverUri: https://cse.cn-north-1.myhuaweicloud.com 28 | 29 | rest: 30 | server: 31 | thread-count: 10 32 | 33 | credentials: 34 | accessKey: xx 35 | secretKey: xx 36 | akskCustomCipher: default 37 | 38 | handler: 39 | chain: 40 | Provider: 41 | default: qps-flowcontrol-provider,bizkeeper-provider,pack-provider 42 | Consumer: 43 | default: qps-flowcontrol-consumer,loadbalance,bizkeeper-consumer,pack-consumer 44 | 45 | monitor: 46 | client: 47 | enable: false 48 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-service/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-service/src/main/java/com/huawei/cse/houseapp/customer/CustomerApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.customer; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 7 | 8 | @SpringBootApplication 9 | @EnableServiceComb 10 | @EnableConfigurationProperties 11 | public class CustomerApplication { 12 | public static void main(String[] args) throws Exception { 13 | try { 14 | SpringApplication.run(CustomerApplication.class, args); 15 | } catch (Exception e) { 16 | e.printStackTrace(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-service/src/main/java/com/huawei/cse/houseapp/customer/service/ConfigurationPropertiesModel.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.customer.service; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "cse.test.house") 8 | public class ConfigurationPropertiesModel { 9 | private String modelValue; 10 | 11 | private String yamlValue; 12 | 13 | private String yamlValueOverride; 14 | 15 | public String getModelValue() { 16 | return modelValue; 17 | } 18 | 19 | public void setModelValue(String modelValue) { 20 | this.modelValue = modelValue; 21 | } 22 | 23 | public String getYamlValueOverride() { 24 | return yamlValueOverride; 25 | } 26 | 27 | public void setYamlValueOverride(String yamlValueOverride) { 28 | this.yamlValueOverride = yamlValueOverride; 29 | } 30 | 31 | public String getYamlValue() { 32 | return yamlValue; 33 | } 34 | 35 | public void setYamlValue(String yamlValue) { 36 | this.yamlValue = yamlValue; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | COPY ./customer-service/target/customer-service-0.0.1-SNAPSHOT.jar /home/apps/server 4 | COPY ./customer-service/target/lib/ /home/apps/server/lib 5 | ENTRYPOINT ["java", "-Dcse.tcc.transaction.redis.host=${TCC_REDIS_HOST}", "-Dcse.tcc.transaction.redis.port=${TCC_REDIS_PORT}", "-Dcse.tcc.transaction.redis.password=${TCC_REDIS_PASSWD}", "-jar", "/home/apps/server/customer-service-0.0.1-SNAPSHOT.jar"] 6 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-service/src/main/resources/META-INF/spring/customer.bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | ## Spring Boot configurations 4 | # omega need this name 5 | spring: 6 | application: 7 | name: customer-service 8 | main: 9 | allow-bean-definition-overriding: true 10 | 11 | server: 12 | port: 9093 13 | 14 | ## CSE configurations 15 | cse: 16 | rest: 17 | address: 0.0.0.0:9093 18 | test: 19 | house: 20 | yamlValueOverride: xyz 21 | 22 | # alpha 23 | alpha: 24 | cluster: 25 | address: 127.0.0.1:7080 -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | com.huawei.cse.houseapp 6 | houseapp 7 | 0.0.1-SNAPSHOT 8 | 9 | 4.0.0 10 | 11 | customer-website 12 | jar 13 | 14 | 15 | 16 | com.huawei.cse.houseapp 17 | common 18 | 0.0.1-SNAPSHOT 19 | 20 | 21 | 22 | 23 | 24 | 25 | org.apache.maven.plugins 26 | maven-dependency-plugin 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-maven-plugin 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/java/com/huawei/cse/houseapp/website/WebsiteApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.website; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class WebsiteApplication { 10 | public static void main(String[] args) throws Exception { 11 | SpringApplication.run(WebsiteApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | ## Spring Boot configurations 4 | server: 5 | port: 9091 6 | spring: 7 | application: 8 | name: customer-website 9 | 10 | ## CSE configurations 11 | cse: 12 | rest: 13 | address: 0.0.0.0:9091 14 | ## static web site will token root 15 | servlet: 16 | urlPattern: /api/* 17 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | contextConfigLocation 8 | 9 | classpath*:META-INF/spring/*.bean.xml 10 | classpath*:app-config.xml 11 | 12 | 13 | 14 | 15 | org.apache.servicecomb.transport.rest.servlet.RestServletContextListener 16 | 17 | 18 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | body{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-bottom:50px}.bs-docs-masthead,.bs-docs-header{color:#cdbfe3;text-shadow:0 1px 0 rgba(0,0,0,0.1);background-color:#6f5499;background-image:-webkit-gradient(linear,left top,left bottom,from(#563d7c),to(#6f5499));background-image:-webkit-linear-gradient(top,#563d7c 0,#6f5499 100%);background-image:linear-gradient(to bottom,#563d7c 0,#6f5499 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#563d7c',endColorstr='#6F5499',GradientType=0);background-repeat:repeat-x}.bs-docs-masthead h1{font-weight:500}.page-header{text-align:left}#github{display:none;position:fixed;width:150px;height:150px;top:0;right:0;z-index:2000}.bottom{border-top:1px solid #eee;margin-top:40px;padding-top:20px;padding-bottom:20px;text-align:center}.hljs{background-color:transparent}@media (min-width:768px){#github{display:block}} -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1489246971535.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1489246971535.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1493696851151.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1493696851151.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1496214523346.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1496214523346.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1496236247761.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/1496236247761.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/2017091022471293.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/2017091022471293.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/20170911192746247 (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/20170911192746247 (1).jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/20170911192746247.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/20170911192746247.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/20170914182855928.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/20170914182855928.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1477897959639mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1477897959639mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1490921883474mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1490921883474mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1494902274982mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1494902274982mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1500629825123mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1500629825123mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1503399072486mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1503399072486mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1503976624403mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1503976624403mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504595886092mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504595886092mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504748150715mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504748150715mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504748540340mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504748540340mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504837511355mp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/428_428_1504837511355mp.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/apple-1485458_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/apple-1485458_960_720.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/arrow.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/card.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/cart.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/cherries-1991042_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/cherries-1991042_960_720.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/edit.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/grapes-1990789_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/grapes-1990789_960_720.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu1.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu2.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu3.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/huxingtu4.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/img-sp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/img-sp.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/lemons-2035490_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/lemons-2035490_960_720.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/logout_16px_27579_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/logout_16px_27579_easyicon.net.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/offer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/offer.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/pears-1990797_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/pears-1990797_960_720.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/settings_16.832px_1182692_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/settings_16.832px_1182692_easyicon.net.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/shopping_cart_16px_1093629_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/shopping_cart_16px_1093629_easyicon.net.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/shopping_cart_empty_16px_1117680_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/shopping_cart_empty_16px_1117680_easyicon.net.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/star.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/star1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/star1.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/strawberry-1485456_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/strawberry-1485456_960_720.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/tag.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/user_13.394714407502px_1206721_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/user_13.394714407502px_1206721_easyicon.net.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/下载.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/customer-website/src/main/resources/static/images/下载.jpg -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/index_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/customer-website/src/main/resources/static/js/counterup.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jquery.counterup.js 1.0 3 | * 4 | * Copyright 2013, Benjamin Intal http://gambit.ph @bfintal 5 | * Released under the GPL v2 License 6 | * 7 | * Date: Nov 26, 2013 8 | */(function(e){"use strict";e.fn.counterUp=function(t){var n=e.extend({time:400,delay:10},t);return this.each(function(){var t=e(this),r=n,i=function(){var e=[],n=r.time/r.delay,i=t.text(),s=/[0-9]+,[0-9]+/.test(i);i=i.replace(/,/g,"");var o=/^[0-9]+$/.test(i),u=/^[0-9]+\.[0-9]+$/.test(i),a=u?(i.split(".")[1]||[]).length:0;for(var f=n;f>=1;f--){var l=parseInt(i/n*f);u&&(l=parseFloat(i/n*f).toFixed(a));if(s)while(/(\d+)(\d{3})/.test(l.toString()))l=l.toString().replace(/(\d+)(\d{3})/,"$1,$2");e.unshift(l)}t.data("counterup-nums",e);t.text("0");var c=function(){t.text(t.data("counterup-nums").shift());if(t.data("counterup-nums").length)setTimeout(t.data("counterup-func"),r.delay);else{delete t.data("counterup-nums");t.data("counterup-nums",null);t.data("counterup-func",null)}};t.data("counterup-func",c);setTimeout(t.data("counterup-func"),r.delay)};t.waypoint(i,{offset:"100%",triggerOnce:!0})})}})(jQuery); -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/deployment/configmap-templates/cse-credentials.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: cse-credential 5 | namespace: default 6 | data: 7 | certificate.yaml: | 8 | cse: 9 | credentials: 10 | accessKey: ak 11 | secretKey: sk 12 | akskCustomCipher: default 13 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/deployment/configmap-templates/mysql-accountdb.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: mysql-accountdb 5 | namespace: default 6 | data: 7 | db.host: "192.168.244.231" 8 | db.port: "8635" 9 | db.dbname: account_db 10 | db.username: root 11 | db.password: password 12 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/deployment/configmap-templates/mysql-productdb.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: mysql-productdb 5 | namespace: default 6 | data: 7 | db.host: "192.168.244.231" 8 | db.port: "8635" 9 | db.dbname: product_db 10 | db.username: root 11 | db.password: password 12 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/deployment/configmap-templates/mysql-userdb.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: mysql-userdb 5 | namespace: default 6 | data: 7 | db.host: "192.168.244.231" 8 | db.port: "8635" 9 | db.dbname: user_db 10 | db.username: root 11 | db.password: password 12 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/deployment/configmap-templates/redis-credential.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: redis-credential 5 | namespace: default 6 | data: 7 | cse.tcc.transaction.redis.host: "192.168.244.231" 8 | cse.tcc.transaction.redis.port: "6379" 9 | cse.tcc.transaction.redis.password: redis-password 10 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/docs/images/system-components.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/docs/images/system-components.JPG -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/docs/images/ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/HouseAppWithSpringBoot2/docs/images/ui.png -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/docs/microservice_technology_introduction.md: -------------------------------------------------------------------------------- 1 | # 微服务技术选型介绍 2 | 3 | account-service、customer-service、product-service、user-service 4 | 底座采用spring boot,集成CSE的REST Servlet,往服务中心注册,并采用CSE的运行时。 选型介绍参考: https://bbs.huaweicloud.com/blogs/eca98a6f399a11e9bd5a7ca23e93a891 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/edge-service/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/edge-service/src/main/java/com/huawei/cse/houseapp/edge/EdgeApplication.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 | 17 | package com.huawei.cse.houseapp.edge; 18 | 19 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 20 | import org.springframework.boot.SpringApplication; 21 | import org.springframework.boot.autoconfigure.SpringBootApplication; 22 | 23 | @SpringBootApplication 24 | @EnableServiceComb 25 | public class EdgeApplication { 26 | public static void main(String[] args) throws Exception { 27 | SpringApplication.run(EdgeApplication.class, args); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/edge-service/src/main/java/com/huawei/cse/houseapp/edge/RedirectToLoginDispatcher.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.edge; 2 | 3 | import org.apache.servicecomb.edge.core.AbstractEdgeDispatcher; 4 | 5 | import io.vertx.ext.web.Router; 6 | import io.vertx.ext.web.RoutingContext; 7 | import io.vertx.ext.web.handler.CookieHandler; 8 | 9 | //优先级最低的转发器,将请求重定向到登录页面。 10 | public class RedirectToLoginDispatcher extends AbstractEdgeDispatcher { 11 | @Override 12 | public int getOrder() { 13 | return 13; 14 | } 15 | 16 | @Override 17 | public void init(Router router) { 18 | router.routeWithRegex("/").handler(CookieHandler.create()); 19 | router.routeWithRegex("/").handler(createBodyHandler()); 20 | router.routeWithRegex("/").failureHandler(this::onFailure).handler(this::onRequest); 21 | } 22 | 23 | protected void onRequest(RoutingContext context) { 24 | context.response().setStatusCode(302); 25 | context.response().putHeader("Location", "/ui/customer-website/login.html"); 26 | context.response().end(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/edge-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | COPY ./edge-service/target/edge-service-0.0.1-SNAPSHOT.jar /home/apps/server 4 | COPY ./edge-service/target/lib/ /home/apps/server/lib 5 | ENTRYPOINT ["java", "-jar", "/home/apps/server/edge-service-0.0.1-SNAPSHOT.jar"] 6 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/edge-service/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter: -------------------------------------------------------------------------------- 1 | # 当前版本不支持ContextParameter,暂时在ApiDispatcher里面使用HTTP Header来增加用户ID. 2 | # com.huawei.cse.houseapp.edge.AuthFilter -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/edge-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher: -------------------------------------------------------------------------------- 1 | com.huawei.cse.houseapp.edge.LoginDispatcher 2 | com.huawei.cse.houseapp.edge.ApiDispatcher 3 | com.huawei.cse.houseapp.edge.WebPageDispatcher 4 | com.huawei.cse.houseapp.edge.RedirectToLoginDispatcher -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/edge-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | # omega need this name 4 | spring: 5 | application: 6 | name: edge-service 7 | 8 | ## CSE configurations 9 | cse: 10 | rest: 11 | address: 0.0.0.0:18080 12 | 13 | http: 14 | dispatcher: 15 | edge: 16 | api: 17 | enabled: true 18 | default: 19 | prefix: api 20 | withVersion: false 21 | prefixSegmentCount: 2 22 | handler: 23 | chain: 24 | Provider: 25 | default: tracing-provider 26 | Consumer: 27 | default: tracing-consumer,loadbalance -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | com.huawei.cse.houseapp 7 | houseapp 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | init-db 13 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | from 100.125.0.198:20202/servicestage/mysqlutf8:0.2 2 | COPY ./init-db/target/sql /sql 3 | COPY ./init-db/target/entrypoint.sh / 4 | RUN chmod +x /entrypoint.sh 5 | ENTRYPOINT ["./entrypoint.sh"] 6 | CMD ["--help"] 7 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/src/main/resources/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ARG1=$1 4 | if [ "--help" = "${ARG1}" -o -z "${ARG1}" ]; then 5 | mysql --help 6 | exit 0 7 | fi 8 | 9 | if [ -f "${ARG1}" ]; then 10 | mysql -u "${DB_USERNAME}" -p"${DB_PASSWD}" -h "${DB_HOST}" -P "${DB_PORT}" < "${ARG1}" 11 | exit $? 12 | else 13 | echo "${ARG1}" > /tmp/tmp.sql 14 | mysql -u "${DB_USERNAME}" -p"${DB_PASSWD}" -h "${DB_HOST}" -P "${DB_PORT}" < "/tmp/tmp.sql" 15 | exit $? 16 | fi -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/src/main/resources/sql/clear.sql: -------------------------------------------------------------------------------- 1 | use account_db; 2 | delete from T_ACCOUNT; 3 | 4 | use product_db; 5 | delete from T_PRODUCT; 6 | 7 | use user_db; 8 | delete from T_USER; 9 | 10 | use saga; 11 | delete from command; 12 | delete from tccfinishedevent; 13 | delete from tccparticipateevent; 14 | delete from txevent; 15 | delete from txtimeout; -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/src/main/resources/sql/create_db_account.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS account_db; 2 | 3 | USE account_db; 4 | 5 | DROP TABLE IF EXISTS T_ACCOUNT; 6 | 7 | CREATE TABLE `T_ACCOUNT` ( 8 | `ID` INTEGER(20) NOT NULL COMMENT '用户ID', 9 | `TOTAL_BALANCE` DECIMAL(16,2) NOT NULL COMMENT '价格', 10 | `RESERVED` TINYINT(1) NOT NULL COMMENT '是否预定', 11 | PRIMARY KEY (`ID`) 12 | ) 13 | ENGINE=InnoDB 14 | DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci 15 | ; 16 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/src/main/resources/sql/create_db_product.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS product_db; 2 | 3 | USE product_db; 4 | 5 | DROP TABLE IF EXISTS T_PRODUCT; 6 | 7 | CREATE TABLE `T_PRODUCT` ( 8 | `ID` INTEGER(20) NOT NULL COMMENT '产品ID', 9 | `PROD_NAME` VARCHAR(20) NOT NULL COMMENT '产品名称', 10 | `RESERVED` TINYINT(1) NOT NULL COMMENT '是否预定', 11 | `PRICE` DECIMAL(16,2) NOT NULL COMMENT '价格', 12 | `SOLD` TINYINT(1) NOT NULL COMMENT '是否预定', 13 | `RESERVED_USERID` INTEGER(20) NOT NULL COMMENT '锁定用户', 14 | PRIMARY KEY (`ID`) 15 | ) 16 | ENGINE=InnoDB 17 | DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci 18 | ; 19 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/init-db/src/main/resources/sql/create_db_user.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS user_db; 2 | 3 | USE user_db; 4 | 5 | DROP TABLE IF EXISTS T_USER; 6 | 7 | CREATE TABLE `T_USER` ( 8 | `ID` INTEGER(20) NOT NULL COMMENT '产品ID', 9 | `USER_NAME` VARCHAR(20) NOT NULL COMMENT '用户名称', 10 | `TOTAL_BALANCE` DECIMAL(16,2) NOT NULL COMMENT '价格', 11 | `RESERVED` TINYINT(1) NOT NULL COMMENT '是否预定', 12 | PRIMARY KEY (`ID`) 13 | ) 14 | ENGINE=InnoDB 15 | DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci 16 | ; 17 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/loadtestclient/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/loadtestclient/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | com.huawei.cse.houseapp 6 | houseapp 7 | 0.0.1-SNAPSHOT 8 | 9 | 4.0.0 10 | 11 | loadtestclient 12 | 13 | 14 | 15 | com.huawei.cse.houseapp 16 | common 17 | 0.0.1-SNAPSHOT 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-dependency-plugin 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/loadtestclient/src/main/java/com/huawei/cse/houseapp/loadtest/LoadApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.loadtest; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class LoadApplication { 10 | public static void main(String[] args) throws Exception { 11 | SpringApplication.run(LoadApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/loadtestclient/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | COPY ./loadtestclient/target/loadtestclient-0.0.1-SNAPSHOT.jar /home/apps/server 4 | COPY ./loadtestclient/target/lib/ /home/apps/server/lib 5 | ENTRYPOINT ["java", "-jar", "/home/apps/server/loadtestclient-0.0.1-SNAPSHOT.jar"] 6 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/loadtestclient/src/main/resources/META-INF/spring/load.bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/loadtestclient/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | ## Spring Boot configurations 4 | server: 5 | port: 8088 6 | spring: 7 | application: 8 | name: loadtestclient 9 | ## CSE configurations 10 | cse: 11 | rest: 12 | address: 0.0.0.0:8088 13 | handler: 14 | chain: 15 | Provider: 16 | default: tracing-provider 17 | Consumer: 18 | default: tracing-consumer,loadbalance -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/product-service/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/product-service/src/main/java/com/huawei/cse/houseapp/product/ProductApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.product; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class ProductApplication { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(ProductApplication.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/product-service/src/main/java/com/huawei/cse/houseapp/product/dao/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.product.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.huawei.cse.houseapp.product.api.ProductInfo; 6 | 7 | public interface ProductMapper { 8 | List getAllProducts(); 9 | 10 | void createProduct(ProductInfo info); 11 | 12 | ProductInfo getProductInfo(long productId); 13 | 14 | void updateProductInfo(ProductInfo info); 15 | 16 | void clear(); 17 | 18 | Double queryReduced(); 19 | } 20 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/product-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | COPY ./product-service/target/product-service-0.0.1-SNAPSHOT.jar /home/apps/server 4 | COPY ./product-service/target/lib/ /home/apps/server/lib 5 | ENTRYPOINT ["java", "-Ddb.url=jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}", "-Ddb.username=${DB_USERNAME}", "-Ddb.password=${DB_PASSWD}", "-Dcse.tcc.transaction.redis.host=${TCC_REDIS_HOST}", "-Dcse.tcc.transaction.redis.port=${TCC_REDIS_PORT}", "-Dcse.tcc.transaction.redis.password=${TCC_REDIS_PASSWD}", "-Dcse.tcc.transaction.repository=com.huawei.paas.cse.tcc.repository.RedisTransactionRepository", "-jar", "/home/apps/server/product-service-0.0.1-SNAPSHOT.jar"] 6 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/product-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | ## Spring Boot configurations 4 | spring: 5 | application: 6 | name: product-service 7 | main: 8 | allow-bean-definition-overriding: true 9 | server: 10 | port: 8089 11 | 12 | ## CSE configurations 13 | cse: 14 | rest: 15 | address: 0.0.0.0:8089 16 | # alpha 17 | alpha: 18 | cluster: 19 | address: 127.0.0.1:7080 -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/product-service/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/product-service/src/main/resources/dbcp.properties: -------------------------------------------------------------------------------- 1 | db.url=jdbc:mysql://localhost/product_db?useSSL=false 2 | db.driver=com.mysql.jdbc.Driver 3 | db.username=root 4 | db.password=root -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | huaweicloud 10 | *,!HuaweiCloudSDK 11 | https://repo.huaweicloud.com/repository/maven/ 12 | 13 | 14 | 15 | 16 | 17 | MyProfile 18 | 19 | 20 | HuaweiCloudSDK 21 | https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/ 22 | 23 | true 24 | 25 | 26 | false 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | MyProfile 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/start.bat: -------------------------------------------------------------------------------- 1 | set CURRENT_DIR=%cd% 2 | 3 | cd %CURRENT_DIR%\account-service\target 4 | start java -jar account-service-0.0.1-SNAPSHOT.jar 5 | 6 | ping 100.1.1.2 -n 1 -w 10000 > nul 7 | 8 | cd %CURRENT_DIR%\customer-service\target 9 | start java -jar customer-service-0.0.1-SNAPSHOT.jar 10 | 11 | ping 100.1.1.2 -n 1 -w 10000 > nul 12 | 13 | cd %CURRENT_DIR%\customer-website\target 14 | start java -jar customer-website-0.0.1-SNAPSHOT.jar 15 | 16 | ping 100.1.1.2 -n 1 -w 10000 > nul 17 | 18 | cd %CURRENT_DIR%\product-service\target 19 | start java -jar product-service-0.0.1-SNAPSHOT.jar 20 | 21 | ping 100.1.1.2 -n 1 -w 10000 > nul 22 | 23 | cd %CURRENT_DIR%\user-service\target 24 | start java -jar user-service-0.0.1-SNAPSHOT.jar 25 | 26 | ping 100.1.1.2 -n 1 -w 10000 > nul 27 | 28 | cd %CURRENT_DIR%\edge-service\target 29 | start java -jar edge-service-0.0.1-SNAPSHOT.jar 30 | 31 | cd %CURRENT_DIR% 32 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.162.197.95:5000/cse-jre:8u111 2 | RUN mkdir -p /home/apps/server 3 | COPY product-service-0.0.1-SNAPSHOT.jar /home/apps/server 4 | COPY lib/ /home/apps/server/lib 5 | ENTRYPOINT ["java", "-jar", "/home/apps/server/product-service-0.0.1-SNAPSHOT.jar"] 6 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/src/main/java/com/huawei/cse/houseapp/user/UserApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.user; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class UserApplication { 10 | public static void main(String[] args) throws Exception { 11 | SpringApplication.run(UserApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/src/main/java/com/huawei/cse/houseapp/user/dao/MockedUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.user.dao; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.huawei.cse.houseapp.user.api.UserInfo; 7 | 8 | public class MockedUserMapper implements UserMapper { 9 | Map users = new HashMap<>(); 10 | 11 | public MockedUserMapper() { 12 | } 13 | 14 | @Override 15 | public UserInfo getUserInfo(long userid) { 16 | return users.get(userid); 17 | } 18 | 19 | @Override 20 | public void updateUserInfo(UserInfo info) { 21 | // reference already changed 22 | } 23 | 24 | @Override 25 | public void createUser(UserInfo info) { 26 | users.putIfAbsent(info.getUserId(), info); 27 | } 28 | 29 | @Override 30 | public void clear() { 31 | users.clear(); 32 | } 33 | 34 | @Override 35 | public Double queryReduced() { 36 | double remain = 0; 37 | for(UserInfo i : users.values()) { 38 | remain = remain + i.getTotalBalance(); 39 | } 40 | return users.size() * 10000000D - remain; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/src/main/java/com/huawei/cse/houseapp/user/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.houseapp.user.dao; 2 | 3 | import com.huawei.cse.houseapp.user.api.UserInfo; 4 | 5 | public interface UserMapper { 6 | void createUser(UserInfo userInfo); 7 | 8 | UserInfo getUserInfo(long userId); 9 | 10 | void updateUserInfo(UserInfo info); 11 | 12 | void clear(); 13 | 14 | Double queryReduced(); 15 | } 16 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | COPY ./user-service/target/user-service-0.0.1-SNAPSHOT.jar /home/apps/server 4 | COPY ./user-service/target/lib/ /home/apps/server/lib 5 | ENTRYPOINT ["java", "-Ddb.url=jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}", "-Ddb.username=${DB_USERNAME}", "-Ddb.password=${DB_PASSWD}", "-Dcse.tcc.transaction.redis.host=${TCC_REDIS_HOST}", "-Dcse.tcc.transaction.redis.port=${TCC_REDIS_PORT}", "-Dcse.tcc.transaction.redis.password=${TCC_REDIS_PASSWD}", "-jar", "/home/apps/server/user-service-0.0.1-SNAPSHOT.jar"] -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | ## Spring Boot configurations 4 | spring: 5 | application: 6 | name: user-service 7 | main: 8 | allow-bean-definition-overriding: true 9 | server: 10 | port: 8092 11 | ## CSE configurations 12 | cse: 13 | rest: 14 | address: 0.0.0.0:8092 15 | # alpha 16 | alpha: 17 | cluster: 18 | address: 127.0.0.1:7080 -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /HouseAppWithSpringBoot2/user-service/src/main/resources/dbcp.properties: -------------------------------------------------------------------------------- 1 | db.url=jdbc:mysql://localhost/user_db?useSSL=false 2 | db.driver=com.mysql.jdbc.Driver 3 | db.username=root 4 | db.password=root -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 本工程是CSE提供的示例项目。 2 | 3 | 4 | # 项目索引 5 | 6 | 7 | 8 | # 开发新项目注意事项 9 | 10 | * 项目提供README.md文件,介绍项目的功能、架构设计、技术选型。 11 | * 介绍项目如何本地编译、执行。 12 | * 介绍项目如何打包为docker镜像,如何部署到云上运行。 13 | -------------------------------------------------------------------------------- /cse-codegen-demo/consumer/src/main/java/com/huawei/paas/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.paas.consumer; 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 ConsumerApplication { 10 | public static void main(String[] args) throws Exception { 11 | SpringApplication.run(ConsumerApplication.class,args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cse-codegen-demo/consumer/src/main/resources/META-INF.spring/cse.consumer.bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /cse-codegen-demo/consumer/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | APPLICATION_ID: helloworld 2 | service_description: 3 | name: myconsumer 4 | version: 0.0.1 5 | properties: 6 | allowCrossApp: true 7 | # environment: development 8 | cse: 9 | service: 10 | registry: 11 | address: http://127.0.0.1:30100 12 | instance: 13 | watch: false 14 | # config: 15 | # client: 16 | # serverUri: https://cse.cn-north-1.myhuaweicloud.com 17 | # refreshMode: 1 18 | # refresh_interval: 5000 19 | # monitor: 20 | # client: 21 | # serverUri: https://cse.cn-north-1.myhuaweicloud.com 22 | rest: 23 | address: 127.0.0.1:8080 24 | #When a local project is deployed as a container outside a cluster, you need to delete all monitor and credentials comments and configure the AK/SK. 25 | # credentials: 26 | # accessKey: your access key 27 | # secretKey: your secret key 28 | # akskCustomCipher: default 29 | # project: cn-north-1 30 | -------------------------------------------------------------------------------- /cse-codegen-demo/provider/src/main/java/com/huawei/paas/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.huawei.paas.provider; 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 ProviderApplication { 10 | public static void main(String[] args) throws Exception { 11 | SpringApplication.run(ProviderApplication.class,args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cse-codegen-demo/provider/src/main/resources/META-INF.spring/cse.consumer.bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /cse-codegen-demo/provider/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | APPLICATION_ID: helloworld 2 | service_description: 3 | name: myprovider 4 | version: 0.0.1 5 | properties: 6 | allowCrossApp: true 7 | # enviroment: development 8 | cse: 9 | service: 10 | registry: 11 | address: http://127.0.0.1:30100 12 | instance: 13 | watch: false 14 | # config: 15 | # client: 16 | # serverUri: https://cse.cn-north-1.myhuaweicloud.com 17 | # refreshMode: 1 18 | # refresh_interval: 5000 19 | # monitor: 20 | # client: 21 | # serverUri: https://cse.cn-north-1.myhuaweicloud.com 22 | rest: 23 | address: 127.0.0.1:8081 24 | #When a local project is deployed as a container outside a cluster, you need to delete all monitor and credentials comments and configure the AK/SK. 25 | # credentials: 26 | # accessKey: your access key 27 | # secretKey: your secret key 28 | # akskCustomCipher: default 29 | # project: cn-north-1 30 | -------------------------------------------------------------------------------- /cse-codegen-doc/clone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/clone.png -------------------------------------------------------------------------------- /cse-codegen-doc/consumer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/consumer.png -------------------------------------------------------------------------------- /cse-codegen-doc/consumerExtra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/consumerExtra.png -------------------------------------------------------------------------------- /cse-codegen-doc/consumerShow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/consumerShow.png -------------------------------------------------------------------------------- /cse-codegen-doc/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/delete.png -------------------------------------------------------------------------------- /cse-codegen-doc/generate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/generate.png -------------------------------------------------------------------------------- /cse-codegen-doc/gitRepoConsumer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/gitRepoConsumer.png -------------------------------------------------------------------------------- /cse-codegen-doc/gitRepoProvider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/gitRepoProvider.png -------------------------------------------------------------------------------- /cse-codegen-doc/provider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/provider.png -------------------------------------------------------------------------------- /cse-codegen-doc/serviceCenter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/serviceCenter.png -------------------------------------------------------------------------------- /cse-codegen-doc/serviceCenterConsumer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/serviceCenterConsumer.png -------------------------------------------------------------------------------- /cse-codegen-doc/serviceCenterDownload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/serviceCenterDownload.png -------------------------------------------------------------------------------- /cse-codegen-doc/yamlConsumer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/yamlConsumer.png -------------------------------------------------------------------------------- /cse-codegen-doc/yamlProvider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/yamlProvider.png -------------------------------------------------------------------------------- /cse-codegen-doc/使用CSE-Codegen插件快速开发微服务.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/cse-codegen-doc/使用CSE-Codegen插件快速开发微服务.pdf -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/java/com/huawei/cse/porter/user/Server.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | public class Server { 7 | public static void main(String[] args) throws Exception { 8 | Log4jUtils.init(); 9 | BeanUtils.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/java/com/huawei/cse/porter/user/dao/SessionMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public interface SessionMapper { 4 | void createSession(SessionInfo sessionInfo); 5 | 6 | SessionInfo getSessioinInfo(String sessionId); 7 | 8 | void updateSessionInfo(String sessionId); 9 | } 10 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/java/com/huawei/cse/porter/user/dao/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public class UserInfo { 4 | private int id; 5 | 6 | private String userName; 7 | 8 | private String password; 9 | 10 | private String roleName; 11 | 12 | public String getUserName() { 13 | return userName; 14 | } 15 | 16 | public void setUserName(String userName) { 17 | this.userName = userName; 18 | } 19 | 20 | public String getPassword() { 21 | return password; 22 | } 23 | 24 | public void setPassword(String password) { 25 | this.password = password; 26 | } 27 | 28 | public String getRoleName() { 29 | return roleName; 30 | } 31 | 32 | public void setRoleName(String roleName) { 33 | this.roleName = roleName; 34 | } 35 | 36 | public int getId() { 37 | return id; 38 | } 39 | 40 | public void setId(int id) { 41 | this.id = id; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/java/com/huawei/cse/porter/user/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public interface UserMapper { 4 | void createUser(UserInfo userInfo); 5 | 6 | UserInfo getUserInfo(String userName); 7 | } 8 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/java/com/huawei/cse/porter/user/endpoint/TimeoutEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.endpoint; 2 | 3 | import java.util.Random; 4 | 5 | import org.apache.servicecomb.provider.rest.common.RestSchema; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | @RestSchema(schemaId = "TimeoutEndpoint") 12 | @RequestMapping(path = "/") 13 | public class TimeoutEndpoint { 14 | Random r = new Random(); 15 | @GetMapping(path = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) 16 | public String hello(@RequestParam("name") String name) { 17 | try { 18 | if(r.nextBoolean()) { 19 | Thread.sleep(1000); 20 | } 21 | 22 | Thread.sleep(1000); 23 | } catch (InterruptedException e) { 24 | // TODO Auto-generated catch block 25 | e.printStackTrace(); 26 | } 27 | return name; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/java/com/huawei/cse/porter/user/endpoint/UserInfoView.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.endpoint; 2 | 3 | import com.huawei.cse.porter.user.dao.UserInfo; 4 | 5 | public class UserInfoView { 6 | private String userName; 7 | 8 | private String roleName; 9 | 10 | public String getUserName() { 11 | return userName; 12 | } 13 | 14 | public void setUserName(String userName) { 15 | this.userName = userName; 16 | } 17 | 18 | public String getRoleName() { 19 | return roleName; 20 | } 21 | 22 | public void setRoleName(String roleName) { 23 | this.roleName = roleName; 24 | } 25 | 26 | public static UserInfoView fromUserInfo(UserInfo userInfo) { 27 | UserInfoView view = new UserInfoView(); 28 | view.setUserName(userInfo.getUserName()); 29 | view.setRoleName(userInfo.getRoleName()); 30 | return view; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/resources/config/create_db_user.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS porter_user_db; 2 | 3 | USE porter_user_db; 4 | 5 | DROP TABLE IF EXISTS T_USER; 6 | 7 | CREATE TABLE `T_USER` ( 8 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '用户ID', 9 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 10 | `PASSWORD` VARCHAR(64) NOT NULL COMMENT '用户密码', 11 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 12 | PRIMARY KEY (`ID`) 13 | ); 14 | 15 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin"); 16 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest"); 17 | 18 | DROP TABLE IF EXISTS T_SESSION; 19 | 20 | CREATE TABLE `T_SESSION` ( 21 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '唯一标识', 22 | `SESSION_ID` VARCHAR(64) NOT NULL COMMENT '临时会话ID', 23 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 24 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 25 | `CREATION_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 26 | `ACTIVE_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近活跃时间', 27 | PRIMARY KEY (`ID`) 28 | ); 29 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /isolation-performance/user-service-a/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | APPLICATION_ID: porter 4 | service_description: 5 | name: user-service-a 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: false 16 | 17 | # for cloud service 18 | # config: 19 | # client: 20 | # refreshMode: 1 21 | # service: 22 | # registry: 23 | # address: https://cse.cn-north-1.myhwclouds.com:443 24 | # instance: 25 | # watch: false 26 | # config: 27 | # client: 28 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 29 | # refreshMode: 1 30 | # refresh_interval: 5000 31 | # monitor: 32 | # client: 33 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 34 | # credentials: 35 | # accessKey: your access key 36 | # secretKey: your secret key 37 | # akskCustomCipher: default 38 | 39 | rest: 40 | address: 0.0.0.0:9095 -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/java/com/huawei/cse/porter/user/dao/SessionMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public interface SessionMapper { 4 | void createSession(SessionInfo sessionInfo); 5 | 6 | SessionInfo getSessioinInfo(String sessionId); 7 | 8 | void updateSessionInfo(String sessionId); 9 | } 10 | -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/java/com/huawei/cse/porter/user/dao/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public class UserInfo { 4 | private int id; 5 | 6 | private String userName; 7 | 8 | private String password; 9 | 10 | private String roleName; 11 | 12 | public String getUserName() { 13 | return userName; 14 | } 15 | 16 | public void setUserName(String userName) { 17 | this.userName = userName; 18 | } 19 | 20 | public String getPassword() { 21 | return password; 22 | } 23 | 24 | public void setPassword(String password) { 25 | this.password = password; 26 | } 27 | 28 | public String getRoleName() { 29 | return roleName; 30 | } 31 | 32 | public void setRoleName(String roleName) { 33 | this.roleName = roleName; 34 | } 35 | 36 | public int getId() { 37 | return id; 38 | } 39 | 40 | public void setId(int id) { 41 | this.id = id; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/java/com/huawei/cse/porter/user/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public interface UserMapper { 4 | void createUser(UserInfo userInfo); 5 | 6 | UserInfo getUserInfo(String userName); 7 | } 8 | -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/java/com/huawei/cse/porter/user/endpoint/TimeoutEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.endpoint; 2 | 3 | import org.apache.servicecomb.provider.rest.common.RestSchema; 4 | import org.springframework.http.MediaType; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | @RestSchema(schemaId = "TimeoutEndpoint") 10 | @RequestMapping(path = "/") 11 | public class TimeoutEndpoint { 12 | @GetMapping(path = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) 13 | public String hello(@RequestParam("name") String name) { 14 | try { 15 | Thread.sleep(1000); 16 | } catch (InterruptedException e) { 17 | // TODO Auto-generated catch block 18 | e.printStackTrace(); 19 | } 20 | return name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/java/com/huawei/cse/porter/user/endpoint/UserInfoView.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.endpoint; 2 | 3 | import com.huawei.cse.porter.user.dao.UserInfo; 4 | 5 | public class UserInfoView { 6 | private String userName; 7 | 8 | private String roleName; 9 | 10 | public String getUserName() { 11 | return userName; 12 | } 13 | 14 | public void setUserName(String userName) { 15 | this.userName = userName; 16 | } 17 | 18 | public String getRoleName() { 19 | return roleName; 20 | } 21 | 22 | public void setRoleName(String roleName) { 23 | this.roleName = roleName; 24 | } 25 | 26 | public static UserInfoView fromUserInfo(UserInfo userInfo) { 27 | UserInfoView view = new UserInfoView(); 28 | view.setUserName(userInfo.getUserName()); 29 | view.setRoleName(userInfo.getRoleName()); 30 | return view; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/resources/config/create_db_user.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS porter_user_db; 2 | 3 | USE porter_user_db; 4 | 5 | DROP TABLE IF EXISTS T_USER; 6 | 7 | CREATE TABLE `T_USER` ( 8 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '用户ID', 9 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 10 | `PASSWORD` VARCHAR(64) NOT NULL COMMENT '用户密码', 11 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 12 | PRIMARY KEY (`ID`) 13 | ); 14 | 15 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin"); 16 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest"); 17 | 18 | DROP TABLE IF EXISTS T_SESSION; 19 | 20 | CREATE TABLE `T_SESSION` ( 21 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '唯一标识', 22 | `SESSION_ID` VARCHAR(64) NOT NULL COMMENT '临时会话ID', 23 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 24 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 25 | `CREATION_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 26 | `ACTIVE_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近活跃时间', 27 | PRIMARY KEY (`ID`) 28 | ); 29 | -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /isolation-performance/user-service-c/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | APPLICATION_ID: porter 4 | service_description: 5 | name: user-service-c 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: false 16 | 17 | # for cloud service 18 | # config: 19 | # client: 20 | # refreshMode: 1 21 | # service: 22 | # registry: 23 | # address: https://cse.cn-north-1.myhwclouds.com:443 24 | # instance: 25 | # watch: false 26 | # config: 27 | # client: 28 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 29 | # refreshMode: 1 30 | # refresh_interval: 5000 31 | # monitor: 32 | # client: 33 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 34 | # credentials: 35 | # accessKey: your access key 36 | # secretKey: your secret key 37 | # akskCustomCipher: default 38 | 39 | rest: 40 | address: 0.0.0.0:9093 41 | loadbalance: 42 | isolation: 43 | enabled: false 44 | retryEnabled: false 45 | handler: 46 | chain: 47 | Provider: 48 | default: "" 49 | Consumer: 50 | default: loadbalance -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/java/com/huawei/cse/porter/user/Client.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | public class Client { 7 | public static void main(String[] args) throws Exception { 8 | Log4jUtils.init(); 9 | BeanUtils.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/java/com/huawei/cse/porter/user/dao/SessionMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public interface SessionMapper { 4 | void createSession(SessionInfo sessionInfo); 5 | 6 | SessionInfo getSessioinInfo(String sessionId); 7 | 8 | void updateSessionInfo(String sessionId); 9 | } 10 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/java/com/huawei/cse/porter/user/dao/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public class UserInfo { 4 | private int id; 5 | 6 | private String userName; 7 | 8 | private String password; 9 | 10 | private String roleName; 11 | 12 | public String getUserName() { 13 | return userName; 14 | } 15 | 16 | public void setUserName(String userName) { 17 | this.userName = userName; 18 | } 19 | 20 | public String getPassword() { 21 | return password; 22 | } 23 | 24 | public void setPassword(String password) { 25 | this.password = password; 26 | } 27 | 28 | public String getRoleName() { 29 | return roleName; 30 | } 31 | 32 | public void setRoleName(String roleName) { 33 | this.roleName = roleName; 34 | } 35 | 36 | public int getId() { 37 | return id; 38 | } 39 | 40 | public void setId(int id) { 41 | this.id = id; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/java/com/huawei/cse/porter/user/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public interface UserMapper { 4 | void createUser(UserInfo userInfo); 5 | 6 | UserInfo getUserInfo(String userName); 7 | } 8 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/java/com/huawei/cse/porter/user/endpoint/TimeoutEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.endpoint; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | import org.apache.servicecomb.provider.rest.common.RestSchema; 6 | import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.client.RestTemplate; 12 | 13 | @RestSchema(schemaId = "TimeoutEndpoint") 14 | @RequestMapping(path = "/") 15 | public class TimeoutEndpoint { 16 | RestTemplate client = RestTemplateBuilder.create(); 17 | AtomicLong counter = new AtomicLong(0); 18 | @GetMapping(path = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) 19 | public String hello(@RequestParam("name") String name) { 20 | long c = counter.incrementAndGet(); 21 | if(c % 10000 == 0) { 22 | System.out.println("************************ \n ************** \n *******get : " + c); 23 | } 24 | return client.getForObject("cse://user-service-a/hello?name=" + name, String.class); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/java/com/huawei/cse/porter/user/endpoint/UserInfoView.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.endpoint; 2 | 3 | import com.huawei.cse.porter.user.dao.UserInfo; 4 | 5 | public class UserInfoView { 6 | private String userName; 7 | 8 | private String roleName; 9 | 10 | public String getUserName() { 11 | return userName; 12 | } 13 | 14 | public void setUserName(String userName) { 15 | this.userName = userName; 16 | } 17 | 18 | public String getRoleName() { 19 | return roleName; 20 | } 21 | 22 | public void setRoleName(String roleName) { 23 | this.roleName = roleName; 24 | } 25 | 26 | public static UserInfoView fromUserInfo(UserInfo userInfo) { 27 | UserInfoView view = new UserInfoView(); 28 | view.setUserName(userInfo.getUserName()); 29 | view.setRoleName(userInfo.getRoleName()); 30 | return view; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/resources/config/create_db_user.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS porter_user_db; 2 | 3 | USE porter_user_db; 4 | 5 | DROP TABLE IF EXISTS T_USER; 6 | 7 | CREATE TABLE `T_USER` ( 8 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '用户ID', 9 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 10 | `PASSWORD` VARCHAR(64) NOT NULL COMMENT '用户密码', 11 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 12 | PRIMARY KEY (`ID`) 13 | ); 14 | 15 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin"); 16 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest"); 17 | 18 | DROP TABLE IF EXISTS T_SESSION; 19 | 20 | CREATE TABLE `T_SESSION` ( 21 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '唯一标识', 22 | `SESSION_ID` VARCHAR(64) NOT NULL COMMENT '临时会话ID', 23 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 24 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 25 | `CREATION_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 26 | `ACTIVE_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近活跃时间', 27 | PRIMARY KEY (`ID`) 28 | ); 29 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /isolation-performance/user-service/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 100 2 | 3 | APPLICATION_ID: porter 4 | service_description: 5 | name: user-service 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: false 16 | 17 | # for cloud service 18 | # config: 19 | # client: 20 | # refreshMode: 1 21 | # service: 22 | # registry: 23 | # address: https://cse.cn-north-1.myhwclouds.com:443 24 | # instance: 25 | # watch: false 26 | # config: 27 | # client: 28 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 29 | # refreshMode: 1 30 | # refresh_interval: 5000 31 | # monitor: 32 | # client: 33 | # serverUri: https://cse.cn-north-1.myhwclouds.com:443 34 | # credentials: 35 | # accessKey: your access key 36 | # secretKey: your secret key 37 | # akskCustomCipher: default 38 | 39 | rest: 40 | address: 0.0.0.0:9092 41 | request: 42 | timeout: 1500 43 | loadbalance: 44 | isolation: 45 | enabled: true 46 | minIsolationTime: 3000 47 | retryEnabled: true -------------------------------------------------------------------------------- /multi-framework/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /multi-framework/auth/src/main/java/com/huawei/cse/AuthMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class AuthMain { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(AuthMain.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /multi-framework/auth/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9092 3 | 4 | service_description: 5 | name: auth 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: http://127.0.0.1:30100 11 | instance: 12 | watch: false 13 | 14 | rest: 15 | address: 0.0.0.0:9092 16 | 17 | ## using spring mvc rest server to handle requests 18 | server.servlet.path: / 19 | servicecomb.rest.servlet.urlPattern: /cse/* 20 | -------------------------------------------------------------------------------- /multi-framework/gateway-service/src/main/java/com/huawei/cse/GatewayMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | public class GatewayMain { 7 | public static void main(String[] args) throws Exception { 8 | Log4jUtils.init(); 9 | BeanUtils.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /multi-framework/gateway-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | RUN mkdir -p /home/apps/server/webapp 4 | COPY porter-gateway-service-0.0.1-SNAPSHOT.jar /home/apps/server 5 | COPY ui /home/apps/server/webapp/ui 6 | WORKDIR /home/apps/server/ 7 | ENTRYPOINT ["java", "-Dgateway.webroot=webapp", "-jar", "porter-gateway-service-0.0.1-SNAPSHOT.jar"] 8 | -------------------------------------------------------------------------------- /multi-framework/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher: -------------------------------------------------------------------------------- 1 | com.huawei.cse.GenericHttpDispatcher 2 | com.huawei.cse.DefaultCseDispatcher 3 | com.huawei.cse.GenericHttpWithDiscoveryDispatcher -------------------------------------------------------------------------------- /multi-framework/gateway-service/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | # override common configurations in common module 2 | cse-config-order: 100 3 | 4 | service_description: 5 | name: gateway 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: http://127.0.0.1:30100 11 | instance: 12 | watch: false 13 | rest: 14 | address: 0.0.0.0:8888?sslEnabled=false 15 | 16 | accesslog: 17 | enabled: true 18 | metrics: 19 | window_time: 30000 20 | publisher.defaultLog.enabled: true 21 | 22 | http.dispatcher: 23 | edge.default.enabled: false 24 | rest.enabled: false 25 | -------------------------------------------------------------------------------- /multi-framework/store/src/main/java/com/huawei/cse/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | 7 | @RequestMapping(path = "/") 8 | public interface AuthService { 9 | @GetMapping(path = "/oauth/token") 10 | Token auth(@RequestParam(name = "username") String username, @RequestParam(name = "password") String password, 11 | @RequestParam(name = "grant_type") String grant_type, 12 | @RequestParam(name = "scope") String scope, 13 | @RequestParam(name = "client_id") String clientId, 14 | @RequestParam(name = "client_secret") String clientSecret); 15 | } 16 | -------------------------------------------------------------------------------- /multi-framework/store/src/main/java/com/huawei/cse/StoreEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse; 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.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | @RestSchema(schemaId = "StoreEndpoint") 10 | @RequestMapping(path = "/") 11 | public class StoreEndpoint { 12 | @RpcReference(microserviceName = "authStub", schemaId="authStub") 13 | private AuthService authService; 14 | 15 | @GetMapping("/product/{id}") 16 | public String getProduct(@PathVariable String id) { 17 | return "product id : " + id; 18 | } 19 | 20 | @GetMapping("/order/{id}") 21 | public String getOrder(@PathVariable String id) { 22 | return "order id : " + id; 23 | } 24 | 25 | @GetMapping("/auth") 26 | public Token auth() { 27 | return authService.auth("user_1", "123456", "password", "read", "client_2", "123456"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /multi-framework/store/src/main/java/com/huawei/cse/StoreMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class StoreMain { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(StoreMain.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /multi-framework/store/src/main/java/com/huawei/cse/Token.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse; 2 | 3 | public class Token { 4 | private String access_token; 5 | private String token_type; 6 | private String refresh_token; 7 | private long expires_in; 8 | private String scope; 9 | private String jti; 10 | public String getAccess_token() { 11 | return access_token; 12 | } 13 | public void setAccess_token(String access_token) { 14 | this.access_token = access_token; 15 | } 16 | public String getToken_type() { 17 | return token_type; 18 | } 19 | public void setToken_type(String token_type) { 20 | this.token_type = token_type; 21 | } 22 | public String getRefresh_token() { 23 | return refresh_token; 24 | } 25 | public void setRefresh_token(String refresh_token) { 26 | this.refresh_token = refresh_token; 27 | } 28 | public long getExpires_in() { 29 | return expires_in; 30 | } 31 | public void setExpires_in(long expires_in) { 32 | this.expires_in = expires_in; 33 | } 34 | public String getScope() { 35 | return scope; 36 | } 37 | public void setScope(String scope) { 38 | this.scope = scope; 39 | } 40 | public String getJti() { 41 | return jti; 42 | } 43 | public void setJti(String jti) { 44 | this.jti = jti; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /multi-framework/store/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9090 3 | 4 | service_description: 5 | name: store 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: http://127.0.0.1:30100 11 | instance: 12 | watch: false 13 | 14 | rest: 15 | address: 0.0.0.0:9090 -------------------------------------------------------------------------------- /multi-framework/user/src/main/java/com/huawei/cse/porter/oauth2/UserEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.oauth2; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class UserEndpoint { 11 | 12 | @GetMapping("/user/{id}") 13 | @ResponseBody 14 | public ResponseEntity getUser(@PathVariable String id) { 15 | System.out.println(id); 16 | return ResponseEntity.ok("user id : " + id); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /multi-framework/user/src/main/java/com/huawei/cse/porter/oauth2/UserMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.oauth2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class UserMain { 8 | public static void main(String[] args) throws Exception { 9 | try { 10 | SpringApplication.run(UserMain.class, args); 11 | } catch (Exception e) { 12 | e.printStackTrace(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /multi-framework/user/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9093 3 | -------------------------------------------------------------------------------- /porter/README.md: -------------------------------------------------------------------------------- 1 | 这个项目帮助开发者学习如何使用CSE开发完整的微服务。 对应的指导文档参考:https://huaweicse.github.io/cse-java-chassis-doc/featured-topics/develop-microservice-using-cse.html 2 | 3 | # 子项目介绍 4 | 5 | 子项目是Porter功能采用不一样的技术栈的实现,他们的业务功能是一样的,只是运行环境有差异,这些差异表现为性能、可以使用的组件等方面。 6 | 7 | * porter_lightweight 8 | 9 | 最轻量级、运行最高效的方式实现Porter应用。静态页面采用js + html + css直接托管到gateway-service。file-service和user-service均采用轻量级Vert.x HTTP服务。 10 | 11 | * porter_springboot2 12 | 13 | gateway-service、file-service和user-service均采用Spring Boot打包运行。其中gateway-service的Web容器依然采用Vert.x HTTP服务, file-service和user-service采用Spring Boot提供的Web容器(Embedded Tomcat)。 14 | 15 | 16 | -------------------------------------------------------------------------------- /porter/porter_lightweight/common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.huawei.cse.porter 8 | porter-application 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | porter-common 13 | jar 14 | 15 | 16 | -------------------------------------------------------------------------------- /porter/porter_lightweight/common/src/main/java/com/huawei/cse/porter/file/api/FileService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.file.api; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | public interface FileService { 6 | public String uploadFile(MultipartFile file); 7 | 8 | public boolean deleteFile(String id); 9 | } 10 | -------------------------------------------------------------------------------- /porter/porter_lightweight/common/src/main/java/com/huawei/cse/porter/user/api/SessionInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.api; 2 | 3 | public class SessionInfo { 4 | private String sessiondId; 5 | 6 | private String userName; 7 | 8 | private String roleName; 9 | 10 | public String getSessiondId() { 11 | return sessiondId; 12 | } 13 | 14 | public void setSessiondId(String sessiondId) { 15 | this.sessiondId = sessiondId; 16 | } 17 | 18 | public String getUserName() { 19 | return userName; 20 | } 21 | 22 | public void setUserName(String userName) { 23 | this.userName = userName; 24 | } 25 | 26 | public String getRoleName() { 27 | return roleName; 28 | } 29 | 30 | public void setRoleName(String roleName) { 31 | this.roleName = roleName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /porter/porter_lightweight/common/src/main/java/com/huawei/cse/porter/user/api/UserService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.api; 2 | 3 | public interface UserService { 4 | public SessionInfo login(String userName, 5 | String password); 6 | 7 | public SessionInfo getSession(String sessionId); 8 | 9 | public String ping(String message); 10 | } 11 | -------------------------------------------------------------------------------- /porter/porter_lightweight/common/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 10 2 | 3 | APPLICATION_ID: porter-application 4 | service_description: 5 | version: 0.0.1 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: https://cse.cn-north-1.myhuaweicloud.com 11 | instance: 12 | watch: false 13 | config: 14 | client: 15 | serverUri: https://cse.cn-north-1.myhuaweicloud.com 16 | refreshMode: 1 17 | refresh_interval: 5000 18 | 19 | credentials: 20 | accessKey: your access key 21 | secretKey: your secret key 22 | akskCustomCipher: default 23 | -------------------------------------------------------------------------------- /porter/porter_lightweight/file-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.huawei.cse.porter 8 | porter-application 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | porter-file-service 13 | jar 14 | 15 | 16 | 17 | com.huawei.cse.porter 18 | porter-common 19 | ${project.parent.version} 20 | 21 | 22 | 23 | com.huawei.cse.porter.file.FileMain 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /porter/porter_lightweight/file-service/src/main/java/com/huawei/cse/porter/file/FileMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.file; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | public class FileMain { 7 | public static void main(String[] args) throws Exception { 8 | Log4jUtils.init(); 9 | BeanUtils.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /porter/porter_lightweight/file-service/src/main/java/com/huawei/cse/porter/file/service/FileStoreService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.file.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | /** 6 | * 提供文件服务,可以有多个实现,比如文件、对象存储服务器、分布式文件存储等。 7 | */ 8 | public interface FileStoreService { 9 | 10 | public String uploadFile(MultipartFile file); 11 | 12 | public boolean deleteFile(String id); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /porter/porter_lightweight/file-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | RUN mkdir -p /home/apps/server/webapp 4 | COPY porter-file-service-0.0.1-SNAPSHOT /home/apps/server 5 | WORKDIR /home/apps/server/ 6 | ENTRYPOINT ["java", "-jar", "porter-file-service-0.0.1-SNAPSHOT"] 7 | -------------------------------------------------------------------------------- /porter/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /porter/porter_lightweight/file-service/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | # override common configurations in common module 2 | cse-config-order: 100 3 | 4 | service_description: 5 | name: file-service 6 | 7 | cse: 8 | rest: 9 | address: 0.0.0.0:9091 10 | 11 | uploads: 12 | directory: tmp_for_upload_file -------------------------------------------------------------------------------- /porter/porter_lightweight/file-service/src/main/resources/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Upload Example 5 | 6 | 7 |

Upload Example

8 |
9 |
11 |

12 | File Name: 13 |

14 |

15 | 16 |

17 |
18 | 19 | -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/java/com/huawei/cse/porter/gateway/EdgeSSLCustom.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.gateway; 2 | 3 | import java.io.File; 4 | 5 | import org.apache.servicecomb.foundation.ssl.SSLCustom; 6 | 7 | public class EdgeSSLCustom extends SSLCustom { 8 | 9 | @Override 10 | public char[] decode(char[] plain) { 11 | return plain; 12 | } 13 | 14 | @Override 15 | public String getFullPath(String name) { 16 | String fullName = System.getProperty("user.dir") + File.separator + name; 17 | System.out.println(fullName); 18 | return (new File(fullName)).getAbsolutePath(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/java/com/huawei/cse/porter/gateway/GatewayMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.gateway; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | public class GatewayMain { 7 | public static void main(String[] args) throws Exception { 8 | Log4jUtils.init(); 9 | BeanUtils.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | RUN mkdir -p /home/apps/server/webapp 4 | COPY porter-gateway-service-0.0.1-SNAPSHOT.jar /home/apps/server 5 | COPY ui /home/apps/server/webapp/ui 6 | WORKDIR /home/apps/server/ 7 | ENTRYPOINT ["java", "-Dgateway.webroot=webapp", "-jar", "porter-gateway-service-0.0.1-SNAPSHOT.jar"] 8 | -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher: -------------------------------------------------------------------------------- 1 | com.huawei.cse.porter.gateway.ApiDispatcher 2 | com.huawei.cse.porter.gateway.StaticWebpageDispatcher -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | # override common configurations in common module 2 | cse-config-order: 100 3 | 4 | service_description: 5 | name: gateway-service 6 | 7 | cse: 8 | rest: 9 | address: 0.0.0.0:9090?sslEnabled=false 10 | 11 | handler: 12 | chain: 13 | Consumer: 14 | default: auth,perf-stats,qps-flowcontrol-consumer,loadbalance,bizkeeper-consumer 15 | 16 | uploads: 17 | directory: tmp_for_upload_gateway 18 | 19 | accesslog: 20 | enabled: true 21 | metrics: 22 | window_time: 30000 23 | publisher.defaultLog.enabled: true 24 | 25 | #########SSL options 26 | ssl.protocols: TLSv1.2 27 | ssl.authPeer: false 28 | ssl.checkCN.host: false 29 | 30 | #########certificates config 31 | ssl.trustStore: trust.jks 32 | ssl.trustStoreType: JKS 33 | ssl.trustStoreValue: Changeme_123 34 | ssl.keyStore: server.p12 35 | ssl.keyStoreType: PKCS12 36 | ssl.keyStoreValue: Changeme_123 37 | ssl.crl: revoke.crl 38 | ssl.sslCustomClass: com.huawei.cse.porter.gateway.EdgeSSLCustom 39 | 40 | servicecomb.http.dispatcher.edge.default.enabled: false 41 | servicecomb.http.dispatcher.rest.enabled: false 42 | gateway.webroot: /code/cse-java-chassis-samples/porter/porter_lightweight/gateway-service/src/main/resources -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/server.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/porter/porter_lightweight/gateway-service/src/main/resources/server.p12 -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/trust.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/porter/porter_lightweight/gateway-service/src/main/resources/trust.jks -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/ui/css/style.css: -------------------------------------------------------------------------------- 1 | .error { 2 | font-family:verdana; 3 | color:red; 4 | } 5 | 6 | .header { 7 | background-color:black; 8 | color:white; 9 | text-align:center; 10 | padding:5px; 11 | } 12 | 13 | .nav { 14 | line-height:30px; 15 | background-color:#eeeeee; 16 | height:300px; 17 | width:100px; 18 | float:left; 19 | padding:5px; 20 | } 21 | 22 | .section { 23 | text-align:center; 24 | padding:5px; 25 | } 26 | 27 | .footer { 28 | color:red; 29 | clear:both; 30 | text-align:center; 31 | padding:25px; 32 | } -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/ui/js/login.js: -------------------------------------------------------------------------------- 1 | function loginAction() { 2 | var username = document.getElementById("username").value; 3 | var password = document.getElementById("paasword").value; 4 | var formData = {}; 5 | formData.userName = username; 6 | formData.password = password; 7 | 8 | $.ajax({ 9 | type: 'POST', 10 | url: "/api/user-service/v1/user/login", 11 | data: formData, 12 | success: function (data) { 13 | console.log(data); 14 | setCookie("session-id", data.sessiondId, 1); 15 | window.location = "/ui/upload.html"; 16 | }, 17 | error: function(data) { 18 | console.log(data); 19 | var error = document.getElementById("error"); 20 | error.textContent="登录失败"; 21 | error.hidden=false; 22 | }, 23 | async: true 24 | }); 25 | } 26 | 27 | function setCookie(name,value,days) { 28 | var expires = ""; 29 | if (days) { 30 | var date = new Date(); 31 | date.setTime(date.getTime() + (days*24*60*60*1000)); 32 | expires = "; expires=" + date.toUTCString(); 33 | } 34 | document.cookie = name + "=" + (value || "") + expires + "; path=/"; 35 | } -------------------------------------------------------------------------------- /porter/porter_lightweight/gateway-service/src/main/resources/ui/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PORTER 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |

登录

14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 |
22 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/java/com/huawei/cse/porter/user/UserMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | public class UserMain { 7 | public static void main(String[] args) throws Exception { 8 | Log4jUtils.init(); 9 | BeanUtils.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/java/com/huawei/cse/porter/user/dao/SessionMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | import com.huawei.cse.porter.user.api.SessionInfo; 4 | 5 | public interface SessionMapper { 6 | void createSession(SessionInfo sessionInfo); 7 | 8 | SessionInfoModel getSessioinInfo(String sessionId); 9 | 10 | void updateSessionInfo(String sessionId); 11 | } 12 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/java/com/huawei/cse/porter/user/dao/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public class UserInfo { 4 | private int id; 5 | 6 | private String userName; 7 | 8 | private String password; 9 | 10 | private String roleName; 11 | 12 | public String getUserName() { 13 | return userName; 14 | } 15 | 16 | public void setUserName(String userName) { 17 | this.userName = userName; 18 | } 19 | 20 | public String getPassword() { 21 | return password; 22 | } 23 | 24 | public void setPassword(String password) { 25 | this.password = password; 26 | } 27 | 28 | public String getRoleName() { 29 | return roleName; 30 | } 31 | 32 | public void setRoleName(String roleName) { 33 | this.roleName = roleName; 34 | } 35 | 36 | public int getId() { 37 | return id; 38 | } 39 | 40 | public void setId(int id) { 41 | this.id = id; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/java/com/huawei/cse/porter/user/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | public interface UserMapper { 4 | void createUser(UserInfo userInfo); 5 | 6 | UserInfo getUserInfo(String userName); 7 | } 8 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | COPY porter-user-service-0.0.1-SNAPSHOT.jar /home/apps/server 4 | WORKDIR /home/apps/server/ 5 | ENTRYPOINT ["java", "-Ddb.url=jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}", "-Ddb.username=${DB_USERNAME}", "-Ddb.password=${DB_PASSWD}", "-jar", "porter-user-service-0.0.1-SNAPSHOT.jar"] 6 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS porter_user_db; 2 | 3 | USE porter_user_db; 4 | 5 | DROP TABLE IF EXISTS T_USER; 6 | 7 | CREATE TABLE `T_USER` ( 8 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '用户ID', 9 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 10 | `PASSWORD` VARCHAR(64) NOT NULL COMMENT '用户密码', 11 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 12 | PRIMARY KEY (`ID`) 13 | ); 14 | 15 | #### password is encrypted for test 16 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin"); 17 | insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest"); 18 | 19 | DROP TABLE IF EXISTS T_SESSION; 20 | 21 | CREATE TABLE `T_SESSION` ( 22 | `ID` INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '唯一标识', 23 | `SESSION_ID` VARCHAR(64) NOT NULL COMMENT '临时会话ID', 24 | `USER_NAME` VARCHAR(64) NOT NULL COMMENT '用户名称', 25 | `ROLE_NAME` VARCHAR(64) NOT NULL COMMENT '角色名称', 26 | `CREATION_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 27 | `ACTIVE_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近活跃时间', 28 | PRIMARY KEY (`ID`) 29 | ); 30 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /porter/porter_lightweight/user-service/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | # override common configurations in common module 2 | cse-config-order: 100 3 | 4 | service_description: 5 | name: user-service 6 | 7 | cse: 8 | rest: 9 | address: 0.0.0.0:9093 -------------------------------------------------------------------------------- /porter/porter_springboot2/common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.huawei.cse.porter 8 | porter-application 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | porter-common 13 | jar 14 | 15 | 16 | -------------------------------------------------------------------------------- /porter/porter_springboot2/common/src/main/java/com/huawei/cse/porter/file/api/FileService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.file.api; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | public interface FileService { 6 | public String uploadFile(MultipartFile file); 7 | 8 | public boolean deleteFile(String id); 9 | } 10 | -------------------------------------------------------------------------------- /porter/porter_springboot2/common/src/main/java/com/huawei/cse/porter/user/api/SessionInfo.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.api; 2 | 3 | public class SessionInfo { 4 | private String sessiondId; 5 | 6 | private String userName; 7 | 8 | private String roleName; 9 | 10 | public String getSessiondId() { 11 | return sessiondId; 12 | } 13 | 14 | public void setSessiondId(String sessiondId) { 15 | this.sessiondId = sessiondId; 16 | } 17 | 18 | public String getUserName() { 19 | return userName; 20 | } 21 | 22 | public void setUserName(String userName) { 23 | this.userName = userName; 24 | } 25 | 26 | public String getRoleName() { 27 | return roleName; 28 | } 29 | 30 | public void setRoleName(String roleName) { 31 | this.roleName = roleName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /porter/porter_springboot2/common/src/main/java/com/huawei/cse/porter/user/api/UserService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.api; 2 | 3 | public interface UserService { 4 | public SessionInfo login(String userName, 5 | String password); 6 | 7 | public SessionInfo getSession(String sessionId); 8 | 9 | public String ping(String message); 10 | } 11 | -------------------------------------------------------------------------------- /porter/porter_springboot2/common/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | cse-config-order: 10 2 | 3 | APPLICATION_ID: porter-application 4 | service_description: 5 | version: 0.0.1 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: https://cse.cn-north-1.myhuaweicloud.com 11 | instance: 12 | watch: false 13 | config: 14 | client: 15 | serverUri: https://cse.cn-north-1.myhuaweicloud.com 16 | refreshMode: 1 17 | refresh_interval: 5000 18 | 19 | credentials: 20 | accessKey: xx 21 | secretKey: xx 22 | akskCustomCipher: default 23 | -------------------------------------------------------------------------------- /porter/porter_springboot2/file-service/src/main/java/com/huawei/cse/porter/file/FileMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.file; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class FileMain { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(FileMain.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /porter/porter_springboot2/file-service/src/main/java/com/huawei/cse/porter/file/service/FileStoreService.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.file.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | /** 6 | * 提供文件服务,可以有多个实现,比如文件、对象存储服务器、分布式文件存储等。 7 | */ 8 | public interface FileStoreService { 9 | 10 | public String uploadFile(MultipartFile file); 11 | 12 | public boolean deleteFile(String id); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /porter/porter_springboot2/file-service/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9091 3 | 4 | service_description: 5 | name: file-service 6 | 7 | cse: 8 | rest: 9 | address: 0.0.0.0:9091 10 | 11 | uploads: 12 | directory: tmp_for_upload_file -------------------------------------------------------------------------------- /porter/porter_springboot2/file-service/src/main/resources/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Upload Example 5 | 6 | 7 |

Upload Example

8 |
9 |
11 |

12 | File Name: 13 |

14 |

15 | 16 |

17 |
18 | 19 | -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/java/com/huawei/cse/porter/gateway/EdgeSSLCustom.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.gateway; 2 | 3 | import java.io.File; 4 | 5 | import org.apache.servicecomb.foundation.ssl.SSLCustom; 6 | 7 | public class EdgeSSLCustom extends SSLCustom { 8 | 9 | @Override 10 | public char[] decode(char[] plain) { 11 | return plain; 12 | } 13 | 14 | @Override 15 | public String getFullPath(String name) { 16 | String fullName = System.getProperty("user.dir") + File.separator + name; 17 | System.out.println(fullName); 18 | return (new File(fullName)).getAbsolutePath(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/java/com/huawei/cse/porter/gateway/GatewayMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.gateway; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class GatewayMain { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(GatewayMain.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/java/com/huawei/cse/porter/gateway/Session.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.gateway; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | import com.huawei.cse.porter.user.api.SessionInfo; 6 | 7 | public interface Session { 8 | public CompletableFuture getSession(String sessionId); 9 | } 10 | -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher: -------------------------------------------------------------------------------- 1 | com.huawei.cse.porter.gateway.ApiDispatcher 2 | com.huawei.cse.porter.gateway.StaticWebpageDispatcher -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | web-application-type: none 4 | 5 | service_description: 6 | name: gateway-service 7 | 8 | cse: 9 | rest: 10 | address: 0.0.0.0:9090?sslEnabled=false 11 | 12 | handler: 13 | chain: 14 | Consumer: 15 | default: auth,perf-stats,qps-flowcontrol-consumer,loadbalance,bizkeeper-consumer 16 | 17 | uploads: 18 | directory: tmp_for_upload_gateway 19 | 20 | accesslog: 21 | enabled: true 22 | metrics: 23 | window_time: 30000 24 | publisher.defaultLog.enabled: true 25 | 26 | #########SSL options 27 | ssl.protocols: TLSv1.2 28 | ssl.authPeer: false 29 | ssl.checkCN.host: false 30 | 31 | #########certificates config 32 | ssl.trustStore: trust.jks 33 | ssl.trustStoreType: JKS 34 | ssl.trustStoreValue: Changeme_123 35 | ssl.keyStore: server.p12 36 | ssl.keyStoreType: PKCS12 37 | ssl.keyStoreValue: Changeme_123 38 | ssl.crl: revoke.crl 39 | ssl.sslCustomClass: com.huawei.cse.porter.gateway.EdgeSSLCustom 40 | 41 | servicecomb.http.dispatcher.edge.default.enabled: false 42 | servicecomb.http.dispatcher.rest.enabled: false 43 | gateway.webroot: /code/cse-java-chassis-samples/porter/porter_lightweight/gateway-service/src/main/resources -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/config/cse.handler.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/server.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/porter/porter_springboot2/gateway-service/src/main/resources/server.p12 -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/trust.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/porter/porter_springboot2/gateway-service/src/main/resources/trust.jks -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/ui/css/style.css: -------------------------------------------------------------------------------- 1 | .error { 2 | font-family:verdana; 3 | color:red; 4 | } 5 | 6 | .header { 7 | background-color:black; 8 | color:white; 9 | text-align:center; 10 | padding:5px; 11 | } 12 | 13 | .nav { 14 | line-height:30px; 15 | background-color:#eeeeee; 16 | height:300px; 17 | width:100px; 18 | float:left; 19 | padding:5px; 20 | } 21 | 22 | .section { 23 | text-align:center; 24 | padding:5px; 25 | } 26 | 27 | .footer { 28 | color:red; 29 | clear:both; 30 | text-align:center; 31 | padding:25px; 32 | } -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/ui/js/login.js: -------------------------------------------------------------------------------- 1 | function loginAction() { 2 | var username = document.getElementById("username").value; 3 | var password = document.getElementById("paasword").value; 4 | var formData = {}; 5 | formData.userName = username; 6 | formData.password = password; 7 | 8 | $.ajax({ 9 | type: 'POST', 10 | url: "/api/user-service/v1/user/login", 11 | data: formData, 12 | success: function (data) { 13 | console.log(data); 14 | setCookie("session-id", data.sessiondId, 1); 15 | window.location = "/ui/upload.html"; 16 | }, 17 | error: function(data) { 18 | console.log(data); 19 | var error = document.getElementById("error"); 20 | error.textContent="登录失败"; 21 | error.hidden=false; 22 | }, 23 | async: true 24 | }); 25 | } 26 | 27 | function setCookie(name,value,days) { 28 | var expires = ""; 29 | if (days) { 30 | var date = new Date(); 31 | date.setTime(date.getTime() + (days*24*60*60*1000)); 32 | expires = "; expires=" + date.toUTCString(); 33 | } 34 | document.cookie = name + "=" + (value || "") + expires + "; path=/"; 35 | } -------------------------------------------------------------------------------- /porter/porter_springboot2/gateway-service/src/main/resources/ui/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PORTER 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |

登录

14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 |
22 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /porter/porter_springboot2/user-service/src/main/java/com/huawei/cse/porter/user/UserMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class UserMain { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(UserMain.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /porter/porter_springboot2/user-service/src/main/java/com/huawei/cse/porter/user/dao/SessionRepository.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | import org.springframework.data.jpa.repository.Query; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface SessionRepository extends CrudRepository { 7 | @Query(value = "select * from T_SESSION s where s.SESSION_ID=?1", nativeQuery = true) 8 | SessionEntity getSessioinInfo(String sessionId); 9 | } 10 | -------------------------------------------------------------------------------- /porter/porter_springboot2/user-service/src/main/java/com/huawei/cse/porter/user/dao/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.user.dao; 2 | 3 | import org.springframework.data.jpa.repository.Query; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface UserRepository extends CrudRepository { 7 | @Query(value = "select * from T_USER u where u.USER_NAME=?1", nativeQuery = true) 8 | UserEntity getUserInfo(String userName); 9 | } 10 | -------------------------------------------------------------------------------- /porter/porter_springboot2/user-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # override common configurations in common module 2 | cse-config-order: 100 3 | 4 | service_description: 5 | name: user-service 6 | 7 | cse: 8 | rest: 9 | address: 0.0.0.0:9093 10 | 11 | # spring jpa datasource 12 | spring.jpa.hibernate.ddl-auto: none 13 | spring.datasource.url: jdbc:mysql://localhost:3306/db_example 14 | spring.datasource.username: springuser 15 | spring.datasource.password: ThePassword -------------------------------------------------------------------------------- /springboot-oauth2-sample/cse-oauth2-resource-server/src/main/java/com/huawei/cse/porter/oauth2/AccessDeniedExceptionConverter.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.oauth2; 2 | 3 | import org.apache.servicecomb.swagger.invocation.Response; 4 | import org.apache.servicecomb.swagger.invocation.SwaggerInvocation; 5 | import org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter; 6 | import org.apache.servicecomb.swagger.invocation.exception.InvocationException; 7 | import org.springframework.security.access.AccessDeniedException; 8 | 9 | public class AccessDeniedExceptionConverter implements ExceptionToProducerResponseConverter { 10 | 11 | @Override 12 | public Response convert(SwaggerInvocation arg0, AccessDeniedException arg1) { 13 | return Response.failResp(new InvocationException(403, "", "access denied by spring security")); 14 | } 15 | 16 | @Override 17 | public Class getExceptionClass() { 18 | return AccessDeniedException.class; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/cse-oauth2-resource-server/src/main/java/com/huawei/cse/porter/oauth2/CustomTokenEnhancer.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/springboot-oauth2-sample/cse-oauth2-resource-server/src/main/java/com/huawei/cse/porter/oauth2/CustomTokenEnhancer.java -------------------------------------------------------------------------------- /springboot-oauth2-sample/cse-oauth2-resource-server/src/main/java/com/huawei/cse/porter/oauth2/OAuth2ResourceServerMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.oauth2; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 7 | 8 | @SpringBootApplication 9 | @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) 10 | @EnableServiceComb 11 | public class OAuth2ResourceServerMain { 12 | public static void main(String[] args) throws Exception { 13 | try { 14 | SpringApplication.run(OAuth2ResourceServerMain.class, args); 15 | } catch (Exception e) { 16 | e.printStackTrace(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/cse-oauth2-resource-server/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter: -------------------------------------------------------------------------------- 1 | com.huawei.cse.porter.oauth2.AccessDeniedExceptionConverter -------------------------------------------------------------------------------- /springboot-oauth2-sample/cse-oauth2-resource-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7071 3 | 4 | service_description: 5 | name: cse-oauth2-resource-server 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: http://127.0.0.1:30100 11 | instance: 12 | watch: false 13 | 14 | rest: 15 | address: 0.0.0.0:7071 16 | 17 | executors: 18 | default: servicecomb.executor.reactive -------------------------------------------------------------------------------- /springboot-oauth2-sample/gateway-service/src/main/java/com/huawei/cse/porter/gateway/GatewayMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.gateway; 2 | 3 | import org.apache.servicecomb.foundation.common.utils.BeanUtils; 4 | import org.apache.servicecomb.foundation.common.utils.Log4jUtils; 5 | 6 | public class GatewayMain { 7 | public static void main(String[] args) throws Exception { 8 | Log4jUtils.init(); 9 | BeanUtils.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/gateway-service/src/main/java/com/huawei/cse/porter/gateway/GenericHttpDispatcher.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/springboot-oauth2-sample/gateway-service/src/main/java/com/huawei/cse/porter/gateway/GenericHttpDispatcher.java -------------------------------------------------------------------------------- /springboot-oauth2-sample/gateway-service/src/main/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-jre-alpine 2 | RUN mkdir -p /home/apps/server 3 | RUN mkdir -p /home/apps/server/webapp 4 | COPY porter-gateway-service-0.0.1-SNAPSHOT.jar /home/apps/server 5 | COPY ui /home/apps/server/webapp/ui 6 | WORKDIR /home/apps/server/ 7 | ENTRYPOINT ["java", "-Dgateway.webroot=webapp", "-jar", "porter-gateway-service-0.0.1-SNAPSHOT.jar"] 8 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher: -------------------------------------------------------------------------------- 1 | com.huawei.cse.porter.gateway.GenericHttpDispatcher -------------------------------------------------------------------------------- /springboot-oauth2-sample/gateway-service/src/main/resources/microservice.yaml: -------------------------------------------------------------------------------- 1 | # override common configurations in common module 2 | cse-config-order: 100 3 | 4 | service_description: 5 | name: gateway-service 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: http://127.0.0.1:30100 11 | instance: 12 | watch: false 13 | rest: 14 | address: 0.0.0.0:8888?sslEnabled=false 15 | 16 | accesslog: 17 | enabled: true 18 | metrics: 19 | window_time: 30000 20 | publisher.defaultLog.enabled: true 21 | 22 | http.dispatcher: 23 | edge.default.enabled: false 24 | rest.enabled: false 25 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/springboot2-oauth2-resource-server/src/main/java/com/huawei/cse/porter/oauth2/CustomTokenEnhancer.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/springboot-oauth2-sample/springboot2-oauth2-resource-server/src/main/java/com/huawei/cse/porter/oauth2/CustomTokenEnhancer.java -------------------------------------------------------------------------------- /springboot-oauth2-sample/springboot2-oauth2-resource-server/src/main/java/com/huawei/cse/porter/oauth2/OAuth2ResourceServerMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.oauth2; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 7 | 8 | @SpringBootApplication 9 | @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) 10 | @EnableServiceComb 11 | public class OAuth2ResourceServerMain { 12 | public static void main(String[] args) throws Exception { 13 | try { 14 | SpringApplication.run(OAuth2ResourceServerMain.class, args); 15 | } catch (Exception e) { 16 | e.printStackTrace(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/springboot2-oauth2-resource-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9090 3 | 4 | service_description: 5 | name: springboot2-oauth2-resource-server 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: http://127.0.0.1:30100 11 | instance: 12 | watch: false 13 | 14 | rest: 15 | address: 0.0.0.0:9090 16 | 17 | ## using spring mvc rest server to handle requests 18 | server.servlet.path: / 19 | servicecomb.rest.servlet.urlPattern: /cse/* 20 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/springboot2-oauth2-server/src/main/java/com/huawei/cse/porter/oauth2/OAuth2ServerConfig.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicse/cse-java-chassis-samples/1ba810940bc12da2b096aace8044d1a9a1735a9a/springboot-oauth2-sample/springboot2-oauth2-server/src/main/java/com/huawei/cse/porter/oauth2/OAuth2ServerConfig.java -------------------------------------------------------------------------------- /springboot-oauth2-sample/springboot2-oauth2-server/src/main/java/com/huawei/cse/porter/oauth2/OAuth2ServerMain.java: -------------------------------------------------------------------------------- 1 | package com.huawei.cse.porter.oauth2; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class OAuth2ServerMain { 10 | public static void main(String[] args) throws Exception { 11 | try { 12 | SpringApplication.run(OAuth2ServerMain.class, args); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /springboot-oauth2-sample/springboot2-oauth2-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7070 3 | 4 | service_description: 5 | name: springboot2-oauth2-server 6 | 7 | cse: 8 | service: 9 | registry: 10 | address: http://127.0.0.1:30100 11 | instance: 12 | watch: false 13 | 14 | rest: 15 | address: 0.0.0.0:7070 16 | 17 | ## using spring mvc rest server to handle requests 18 | server.servlet.path: / 19 | servicecomb.rest.servlet.urlPattern: /cse/* 20 | -------------------------------------------------------------------------------- /springboot-sample/spingboot2-sample-zuul/bussiness/src/main/java/io/provider/BusinessService.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import org.apache.servicecomb.provider.rest.common.RestSchema; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | // @RestController = @RestSchema(schemaId = "io.provider.BusinessService") 9 | // @RestController 10 | 11 | @RestSchema(schemaId = "BusinessService") 12 | @RequestMapping(path = "/user") 13 | public class BusinessService implements IBusinessService { 14 | @GetMapping(path = "hello") 15 | public String hello(@RequestParam(name = "name") String name) { 16 | return String.format("hello %s", name); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /springboot-sample/spingboot2-sample-zuul/bussiness/src/main/java/io/provider/IBusinessService.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | public interface IBusinessService { 4 | public String hello(String name); 5 | } 6 | -------------------------------------------------------------------------------- /springboot-sample/spingboot2-sample-zuul/bussiness/src/main/java/io/provider/ServerMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableServiceComb 9 | public class ServerMain { 10 | public static void main(String[] args) { 11 | try { 12 | SpringApplication.run(ServerMain.class, args); 13 | } catch (Throwable e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /springboot-sample/spingboot2-sample-zuul/bussiness/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: springboot2-sample-zuul-bussiness 4 | 5 | server: 6 | port: 7111 7 | 8 | # CSE RPC 的配置项 9 | # 应用名称 10 | APPLICATION_ID: springboot-sample 11 | # 微服务名称和版本号,微服务名称使用Spring Cloud的名称 12 | service_description: 13 | name: ${spring.application.name} 14 | version: 1.0.0 15 | # 服务中心的地址 16 | servicecomb: 17 | service: 18 | registry: 19 | address: http://localhost:30100 20 | instance: 21 | watch: false 22 | # 对外发布的地址,端口号使用server.port 23 | rest: 24 | address: 0.0.0.0:${server.port} 25 | # 线下开发,关闭监控数据上报 26 | monitor: 27 | client: 28 | enable: false 29 | -------------------------------------------------------------------------------- /springboot-sample/spingboot2-sample-zuul/gateway/src/main/java/io/provider/GatewayMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import org.apache.servicecomb.provider.pojo.RpcReference; 4 | import org.apache.servicecomb.springboot2.starter.EnableServiceComb; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 9 | 10 | @SpringBootApplication 11 | @EnableZuulProxy 12 | @EnableDiscoveryClient 13 | @EnableServiceComb 14 | public class GatewayMain { 15 | @RpcReference(microserviceName = "springboot2-sample-zuul-bussiness", schemaId = "BusinessService") 16 | private static IBusinessService b; 17 | 18 | public static void main(String[] args) { 19 | try { 20 | SpringApplication.run(GatewayMain.class, args); 21 | } catch (Throwable e) { 22 | e.printStackTrace(); 23 | } 24 | 25 | System.out.println(b.hello("World")); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /springboot-sample/spingboot2-sample-zuul/gateway/src/main/java/io/provider/IBusinessService.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | public interface IBusinessService { 4 | public String hello(String name); 5 | } 6 | -------------------------------------------------------------------------------- /springboot-sample/spingboot2-sample-zuul/gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: springboot2-sample-zuul-gateway 4 | 5 | server: 6 | port: 7112 7 | 8 | # CSE RPC 的配置项 9 | # 应用名称 10 | APPLICATION_ID: springboot-sample 11 | # 微服务名称和版本号,微服务名称使用Spring Cloud的名称 12 | service_description: 13 | name: ${spring.application.name} 14 | version: 1.0.0 15 | # 服务中心的地址 16 | servicecomb: 17 | service: 18 | registry: 19 | address: http://localhost:30100 20 | instance: 21 | watch: false 22 | # 对外发布的地址,端口号使用server.port 23 | rest: 24 | address: 0.0.0.0:${server.port} 25 | # 线下开发,关闭监控数据上报 26 | monitor: 27 | client: 28 | enable: false 29 | # 处理链配置 30 | handler: 31 | chain: 32 | Provider: 33 | default: qps-flowcontrol-provider 34 | Consumer: 35 | default: qps-flowcontrol-consumer,loadbalance,fault-injection-consumer 36 | 37 | zuul: 38 | host: 39 | connect-timeout-millis: 60000 40 | socket-timeout-millis: 60000 41 | add-host-header: false 42 | routes: 43 | user: 44 | path: /user/** 45 | service-id: springboot2-sample-zuul-bussiness -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/README.md: -------------------------------------------------------------------------------- 1 | # 本项目演示使用CSE集成使用spring security -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/src/main/java/io/provider/BusinessService.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class BusinessService { 10 | @GetMapping(path = "test") 11 | public String hello(@RequestParam(name = "name") String name) { 12 | return String.format("hello %s", name); 13 | } 14 | 15 | @GetMapping(path = "adminGet") 16 | public String adminGet() { 17 | return "adminGet"; 18 | } 19 | 20 | @PostMapping(path = "adminPost") 21 | public String adminPost() { 22 | return "adminPost"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/src/main/java/io/provider/DeniedInfo.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import java.util.Date; 4 | 5 | public class DeniedInfo { 6 | private Date timestamp; 7 | 8 | private String message; 9 | 10 | private String basicErrorControllerMessage; 11 | 12 | public Date getTimestamp() { 13 | return timestamp; 14 | } 15 | 16 | public void setTimestamp(Date timestamp) { 17 | this.timestamp = timestamp; 18 | } 19 | 20 | public String getMessage() { 21 | return message; 22 | } 23 | 24 | public void setMessage(String message) { 25 | this.message = message; 26 | } 27 | 28 | public String getBasicErrorControllerMessage() { 29 | return basicErrorControllerMessage; 30 | } 31 | 32 | public void setBasicErrorControllerMessage(String basicErrorControllerMessage) { 33 | this.basicErrorControllerMessage = basicErrorControllerMessage; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/src/main/java/io/provider/Hello.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | public interface Hello { 4 | 5 | String sayHi(String name); 6 | } 7 | -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/src/main/java/io/provider/HelloService.java: -------------------------------------------------------------------------------- 1 | package io.provider; 2 | 3 | import org.slf4j.LoggerFactory; 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 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | //@RestSchema(schemaId="hello") 10 | @RestController 11 | @RequestMapping(path = "/hello") 12 | public class HelloService implements Hello { 13 | private static org.slf4j.Logger log = LoggerFactory.getLogger(HelloService.class); 14 | 15 | @Override 16 | @RequestMapping(path = "/sayhi", method = RequestMethod.GET) 17 | public String sayHi(@RequestParam(name = "name", required = false) String name) { 18 | log.info("Access /hello/sayhi, and name is " + name); 19 | return "from provider: Hello " + name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/src/main/java/io/provider/ServerMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 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 ServerMain { 10 | public static void main(String[] args) { 11 | try { 12 | SpringApplication.run(ServerMain.class, args); 13 | } catch (Throwable e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/src/main/resources/META-INF/spring/cse.bean.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /springboot-sample/springboot1-sample-security/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: springboot1-sample-security 4 | 5 | server: 6 | port: 7111 7 | 8 | # CSE RPC 的配置项 9 | # 应用名称 10 | APPLICATION_ID: springboot-sample 11 | # 微服务名称和版本号,微服务名称使用Spring Cloud的名称 12 | service_description: 13 | name: ${spring.application.name} 14 | version: 1.0.0 15 | # 服务中心的地址 16 | servicecomb: 17 | service: 18 | registry: 19 | address: http://localhost:30100 20 | instance: 21 | watch: false 22 | # 对外发布的地址,端口号使用server.port 23 | rest: 24 | address: 0.0.0.0:${server.port} 25 | # 线下开发,关闭监控数据上报 26 | monitor: 27 | client: 28 | enable: false 29 | -------------------------------------------------------------------------------- /springcloud-sample-cse-access/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 | -------------------------------------------------------------------------------- /springcloud-sample-cse-access/springcloud-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springcloud-sample-cse-access/springcloud-consumer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-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-cse-access/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-cse-access/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 | 25 | # modify this imformation to your owner 26 | servicecomb: 27 | credentials: 28 | accessKey: your access key 29 | secretKey: your secret key 30 | akskCustomCipher: default -------------------------------------------------------------------------------- /springcloud-sample-cse-access/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-cse-access/springcloud-provider/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springcloud-sample-cse-access/springcloud-provider/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-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"] -------------------------------------------------------------------------------- /springcloud-sample-cse-access/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 | -------------------------------------------------------------------------------- /springcloud-sample-cse-access/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-cse-access/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 | # modify this imformation to your owner 17 | servicecomb: 18 | credentials: 19 | accessKey: your access key 20 | secretKey: your secret key 21 | akskCustomCipher: default -------------------------------------------------------------------------------- /springcloud-sample-cse-access/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 -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/README.md: -------------------------------------------------------------------------------- 1 | ## SpringCloud使用CSE RPC框架 2 | 3 | 点击获取本项目的[说明文档](https://huaweicse.github.io/cse-java-chassis-doc/spring-cloud-using-cse/cse-and-rpc.html)。 4 | 5 | 说明:本地运行此Demo请参考快速接入指南,在application.yml中增加认证信息,认证信息包含AS/SK,可以从公有云帐号的[我的凭证](https://support.huaweicloud.com/usermanual-iam/zh-cn_topic_0079477318.html)获取,云上部署无需提供认证信息,部署平台将自动认证。 6 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/edge-service/src/main/java/io/provider/EdgeMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 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 EdgeMain { 11 | public static void main(String[] args) throws Exception { 12 | SpringApplication.run(EdgeMain.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/edge-service/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 -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/performance-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/performance-client/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-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"] -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/performance-client/README.md: -------------------------------------------------------------------------------- 1 | ## 服务提供者接入CSE 2 | 3 | ### 镜像构建 4 | 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) 5 | 6 | b. 华为云微服务平台编译时默认使用自带的maven仓库,若使用自定义的maven仓库,可参考以下两种方法: 1、请将您的settings.xml存放到该项目的代码库根目录下; 2、在该项目的pom文件中设置用户repositories配置。 7 | 8 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/performance-client/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 hello(String name); 22 | 23 | String dynamicProperty(); 24 | } 25 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/performance-client/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 -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-consumer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-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-cse-edge/springcloud-consumer/README.md: -------------------------------------------------------------------------------- 1 | ## 服务消费者接入CSE 2 | 3 | ### 镜像构建 4 | 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) 5 | 6 | b. 华为云微服务平台编译时默认使用自带的maven仓库,若使用自定义的maven仓库,可参考以下两种方法: 1、请将您的settings.xml存放到该项目的代码库根目录下; 2、在该项目的pom文件中设置用户repositories配置。 7 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample-cse-edge 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-consumer-cse-edge 10 | 11 | UTF-8 12 | 1.8 13 | 14 | 15 | 16 | 17 | org.apache.servicecomb 18 | spring-boot-starter-provider 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-maven-plugin 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-consumer/src/main/java/io/consumer/ClientMain.java: -------------------------------------------------------------------------------- 1 | package io.consumer; 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 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 8 | 9 | @SpringBootApplication(exclude=DispatcherServletAutoConfiguration.class) 10 | @EnableServiceComb 11 | @EnableConfigurationProperties 12 | public class ClientMain { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(ClientMain.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-consumer/src/main/java/io/consumer/Configuration.java: -------------------------------------------------------------------------------- 1 | package io.consumer; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix="cse.dynamic") 8 | public class Configuration { 9 | private String property; 10 | 11 | public String getProperty() { 12 | return property; 13 | } 14 | 15 | public void setProperty(String property) { 16 | this.property = property; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/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 | public interface Hello { 20 | String sayHi(String name); 21 | } 22 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/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-cse-edge/springcloud-provider/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-provider/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-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"] -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-provider/README.md: -------------------------------------------------------------------------------- 1 | ## 服务提供者接入CSE 2 | 3 | ### 镜像构建 4 | 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) 5 | 6 | b. 华为云微服务平台编译时默认使用自带的maven仓库,若使用自定义的maven仓库,可参考以下两种方法: 1、请将您的settings.xml存放到该项目的代码库根目录下; 2、在该项目的pom文件中设置用户repositories配置。 7 | 8 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample-cse-edge 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-provider-cse-edge 10 | 11 | 12 | UTF-8 13 | 1.8 14 | 15 | 16 | 17 | 18 | org.apache.servicecomb 19 | spring-boot-starter-provider 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-maven-plugin 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/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 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/springcloud-provider/src/main/java/io/provider/ServerMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 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 ServerMain { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(ServerMain.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springcloud-sample-cse-edge/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 -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/README.md: -------------------------------------------------------------------------------- 1 | ## SpringCloud使用CSE RPC框架 2 | 3 | 点击获取本项目的[说明文档](https://huaweicse.github.io/cse-java-chassis-doc/spring-cloud-using-cse/cse-and-rpc.html)。 4 | 5 | 说明:本地运行此Demo请参考快速接入指南,在application.yml中增加认证信息,认证信息包含AS/SK,可以从公有云帐号的[我的凭证](https://support.huaweicloud.com/usermanual-iam/zh-cn_topic_0079477318.html)获取,云上部署无需提供认证信息,部署平台将自动认证。 6 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-consumer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-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-cse-rpc/springcloud-consumer/README.md: -------------------------------------------------------------------------------- 1 | ## 服务消费者接入CSE 2 | 3 | ### 镜像构建 4 | 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) 5 | 6 | b. 华为云微服务平台编译时默认使用自带的maven仓库,若使用自定义的maven仓库,可参考以下两种方法: 1、请将您的settings.xml存放到该项目的代码库根目录下; 2、在该项目的pom文件中设置用户repositories配置。 7 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample-cse-rpc 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-consumer-cse-rpc 10 | 11 | UTF-8 12 | 1.8 13 | 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-web 19 | 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-maven-plugin 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-consumer/src/main/java/io/consumer/ClientMain.java: -------------------------------------------------------------------------------- 1 | package io.consumer; 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 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 8 | 9 | @SpringBootApplication(exclude=DispatcherServletAutoConfiguration.class) 10 | @EnableServiceComb 11 | @EnableConfigurationProperties 12 | public class ClientMain { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(ClientMain.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-consumer/src/main/java/io/consumer/Configuration.java: -------------------------------------------------------------------------------- 1 | package io.consumer; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix="cse.dynamic") 8 | public class Configuration { 9 | private String property; 10 | 11 | public String getProperty() { 12 | return property; 13 | } 14 | 15 | public void setProperty(String property) { 16 | this.property = property; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/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 | public interface Hello { 20 | String sayHi(String name); 21 | } 22 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/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-cse-rpc/springcloud-provider/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-provider/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 100.125.0.198:20202/hwcse/dockerhub-java:8-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"] -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-provider/README.md: -------------------------------------------------------------------------------- 1 | ## 服务提供者接入CSE 2 | 3 | ### 镜像构建 4 | 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) 5 | 6 | b. 华为云微服务平台编译时默认使用自带的maven仓库,若使用自定义的maven仓库,可参考以下两种方法: 1、请将您的settings.xml存放到该项目的代码库根目录下; 2、在该项目的pom文件中设置用户repositories配置。 7 | 8 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | io.case 6 | springcloud-sample-cse-rpc 7 | 0.0.1-SNAPSHOT 8 | 9 | springcloud-provider-cse-rpc 10 | 11 | 12 | UTF-8 13 | 1.8 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-web 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-maven-plugin 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/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 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/springcloud-provider/src/main/java/io/provider/ServerMain.java: -------------------------------------------------------------------------------- 1 | package io.provider; 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 ServerMain { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(ServerMain.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springcloud-sample-cse-rpc/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 -------------------------------------------------------------------------------- /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) -------------------------------------------------------------------------------- /springcloud-sample/eureka-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /springcloud-sample/springcloud-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /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/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-provider/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /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, Integer age); 22 | } 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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}}} --------------------------------------------------------------------------------