当前位置: 首页 > news >正文

中国建设工程招投网站阿里云服务器安装网站

中国建设工程招投网站,阿里云服务器安装网站,柯桥做网站哪家好,徐州免费模板建站一#xff0c;注册中心 最新版使用的是nacos#xff0c;可替换为eureka#xff0c;zookeeper#xff0c;使用方式大同小异#xff0c;这里不做扩展。 下载安装#xff1a;#xff08;有机会重装时再补上#xff09; 管理页面#xff1a;http://localhost:8848/naco…一注册中心 最新版使用的是nacos可替换为eurekazookeeper使用方式大同小异这里不做扩展。 下载安装有机会重装时再补上 管理页面http://localhost:8848/nacos/index.html 二搭建一个springcloud工程 1创建一个maven 父工程pom.xml如下 project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.qi.study/groupIdartifactIdspringcloud/artifactIdversion0.0.1-SNAPSHOT/versionpackagingpom/packagingpropertiesjava.version18/java.versionspring-boot.version2.7.3/spring-boot.versionspring-cloud.version2021.0.3/spring-cloud.versionspring-cloud-alibaba.version2021.1/spring-cloud-alibaba.version/propertiesdependencyManagementdependencies!-- spring boot 依赖 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-dependencies/artifactIdversion${spring-boot.version}/versiontypepom/typescopeimport/scope/dependency!-- spring cloud 依赖 --!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion${spring-cloud.version}/versiontypepom/typescopeimport/scope/dependency!-- spring cloud alibaba 依赖 --!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-alibaba-dependencies --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-alibaba-dependencies/artifactIdversion${spring-cloud-alibaba.version}/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagementmodulesmodulenacos-server/modulemoduleapp-web/modulemoduleapp-service/module/modules /project 2创建三个子工程 modulenacos-server/module moduleapp-web/module moduleapp-service/module 以nacos-server为例添加以下配置代码 1pom.xml project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdcom.qi.study/groupIdartifactIdspringcloud/artifactIdversion0.0.1-SNAPSHOT/version/parentartifactIdnacos-server/artifactIddependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-discovery --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactId/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build /project 2application.yml server:port: 8080spring:application:name: nacos-servercloud:nacos:discovery:server-addr: 127.0.0.1:8848 3Application.java package com.qi.study.springcloud;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;SpringBootApplication EnableDiscoveryClient public class NacosServerApplication {public static void main(String[] args) {SpringApplication.run(NacosServerApplication.class, args);}}其他两个工程app-web 和 app-service 同上面一样只是改一下application.yml配置文件中的端口号和服务名称 #app-webserver:port: 8081spring:application:name: app-webcloud:nacos:discovery:server-addr: 127.0.0.1:8848#app-serviceserver:port: 8082spring:application:name: app-servicecloud:nacos:discovery:server-addr: 127.0.0.1:8848 分别启动三个项目在nacos服务注册中心查看是否注册成功 三添加feign远程接口的调用测试 1调用过程app-web(controller) - feignClient - app-service(controller) 2在工程app-web中添加feign依赖包 dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactId/dependency!--引入openfeign必须要引入loadbalancer否则无法启动--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-loadbalancer/artifactId/dependency 3在启动类Application.java中通过注解EnableFeignClients开启feign功能 package com.qi.study.springcloud;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients;SpringBootApplication EnableDiscoveryClient EnableFeignClients public class AppWebApplication {public static void main(String[] args) {SpringApplication.run(AppWebApplication.class, args);} }4app-web 添加controller测试接口 package com.qi.study.springcloud.controller;import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;import com.qi.study.springcloud.feignClient.AppServiceClient;RestController public class HelloWorldController {private final static Logger LOGGER LoggerFactory.getLogger(HelloWorldController.class);Autowiredprivate AppServiceClient appServiceClient;GetMapping(/helloWorld)public String helloWorld (RequestParam(required false) String msg) {LOGGER.info(app-web 访问helloWorld接口入参 {}, msg);return appServiceClient.helloWorld(msg);} }app-web 添加feignclient远程调用接口重要注解FeignClient(value app-service) package com.qi.study.springcloud.feignClient;import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam;/*** 通过feign远程调用服务app-service的http接口* 特别注意FeignClient这里的value要与app-service在nacos中注册的名称一致否则无法找到* author Admin**/ FeignClient(value app-service) public interface AppServiceClient {GetMapping(/hello)String helloWorld(RequestParam(value msg, defaultValue world,required false) String msg); }app-service 添加逻辑实现接口 package com.qi.study.springcloud.controller;import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;RestController public class HelloController {private final static Logger LOGGER LoggerFactory.getLogger(HelloController.class);GetMapping(/hello)public String hello(RequestParam(value msg, defaultValue world ,required false) String msg) {LOGGER.info(app-service访问接口hello入参 {}, msg);return say hello - .concat(msg);} }同时启动app-web和app-service访问测试 5feign还支持负载均衡无需额外配置保持app-service服务开启修改端口号为8083再次启动可以看到app-service注册的服务变为了两个 多次调用上面的测试接口就能看到两个app-service服务轮流返回数据。  四源代码下载https://download.csdn.net/download/MyNoteBlog/87447400
http://www.w-s-a.com/news/960278/

相关文章:

  • 网站建立风格二手交易网站开发可参考文献
  • 成都微信网站开发优化大师优化项目有哪些
  • 哪个网站做自考题目免费郑州网站建设公司qq
  • 地方性的网站有前途顺的网络做网站好不好
  • 学校申请建设网站的原因不要网站域名
  • 推荐响应式网站建设子域名查询工具
  • 如何建设学校的微网站广告推广是什么
  • 设计类专业哪个就业前景好网站建设seoppt
  • 济南建站公司网站网站友链查询源码
  • 校园失物招领网站建设涪陵网站建设公司
  • 怎么做盗号网站手机网站建设需要租用什么科目
  • 成品网站是什么意思沈阳seo推广
  • 购物网站后台流程图昆明官网seo技术
  • 创建自己网站全网零售管理系统
  • 江苏省建设厅网站建筑电工证wordpress收费插件大全
  • 北京中国建设银行招聘信息网站宁德蕉城住房和城乡建设部网站
  • 泉州做网站优化哪家好wordpress站点预览
  • 创建门户网站一页网站首页图如何做
  • 服装手机商城网站建设sns社交网站有哪些
  • 无锡工程建设招标网站怎么自己建设公司网站
  • 哪个网站可以学做咸菜安卓软件开发需要学什么软件
  • 自有网站建设的团队遂宁市建设局网站
  • 网站建设哪个好一些网站内容导出
  • 什么网站的页面做的比较好看网上做平面设计的网站
  • 网站建设单选网站建设学校培训学校
  • 可以做app的网站logo设计在线生成免费标小智
  • 网站变更备案做酒类网站
  • 网站必须要备案吗东莞市非凡网站建设
  • 太原建网站公司网站设计的流程是怎样的
  • 网站开发交易平台北京网站建设的价格低