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

丽江市建设局网站软件开发流程8个步骤

丽江市建设局网站,软件开发流程8个步骤,wordpress 迁移 hexo,房屋建筑设计网站本文介绍如何使用 springboot3及cloud2023 进行微服务模块化开发 采用父-module 模块开发 父工程 demo-java pom.xml !--配置 springboot的依赖的版本号, 方便 module 进行继承--dependencyManagementdependencies!--增加 springboot的依赖--!--配置 springboot的依赖的版本号, 方便 module 进行继承--dependencyManagementdependencies!--增加 springboot的依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-dependencies/artifactIdversion3.2.5/versiontypepom/typescopeimport/scope/dependency​!--增加 springcloud的依赖--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion2023.0.1/versiontypepom/typescopeimport/scope/dependency​​/dependencies/dependencyManagement​​ 子模块 cloud-eureka-server-7001 pom.xml ​dependencies!--增加 boot web的依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency​!--增加 eureka-server 的依赖--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-server/artifactId/dependency/dependencies​ 启动类: package com.ly;​import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;​SpringBootApplicationEnableEurekaServerpublic class CloudEurekaServer7001 {public static void main(String[] args) {SpringApplication.run(CloudEurekaServer7001.class,args);}}​ 配置文件 application.yml # 设置端口号为 7001server:port: 7001​​eureka:instance:hostname: localhostclient:fetch-registry: false    #如果fetch-registry为false, 则表示自己为注册中心register-with-eureka: false  #表示是否向eureka注册中心注册自己service-url:defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka   # 服务地址​​​​ 启动测试: 子模块 cloud-eureka-provider-8001 pom.xml dependencies!--增加 boot web的依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!--增加 eureka client 依赖--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactId/dependency!--增加 监控 boot 依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependency/dependencies 启动类 package com.ly;​import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.client.discovery.EnableDiscoveryClient;​​SpringBootApplicationEnableDiscoveryClientpublic class EurekaProvider8001 {public static void main(String[] args) {SpringApplication.run(EurekaProvider8001.class,args);}}​ application.yaml ​#设置端口号server:port: 8001​​​eureka:client:fetch-registry: true #是提供者,不是注册中心 ,可省略register-with-eureka: true #向注册中心 注册服务,可省略service-url: #服务地址defaultZone: http://localhost:7001/eureka​​ 刷新 之前的 server 如何 解决 unknow ?修改 provider-8001 的 yaml文件,增加 spring.application.name 为了 模拟 用户管理 ---provider8001 , 订单管理--provider8002, 消费者来 消费服务 子模块 cloud-eureka-common-api pom.xml dependenciesdependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactId/dependency/dependencies 创建 实体层 User.java 与 OrderInfo.java package com.ly.entity;​​import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import lombok.ToString;​/*** 用户 实体*/DataAllArgsConstructorNoArgsConstructorToStringpublic class User {private int userId; //用户编号private String username;//用户名private String phone;//电话}​ package com.ly.entity;​import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import lombok.ToString;​import java.time.LocalDateTime;​/*** 订单 实体*/DataAllArgsConstructorNoArgsConstructorToStringpublic class OrderInfo {private int orderNo;//订单编号private String title;// 标题private double price;//单价private double count;//个数private LocalDateTime time;//购买时间private int userId;// 用户编号}​ 修改 provider8001 的 pom.xml 增加 !--引入 common-api module--dependencygroupIdcom.ly/groupIdartifactIdcloud-eureka-common-api/artifactIdversion1.0-SNAPSHOT/version/dependency 为 provider8001 增加 controller package com.ly.controller;​import com.ly.entity.User;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RestController;​/*** provider8001 --模拟的就是用户管理 模块*/RestControllerpublic class UserController {​GetMapping(/user/{id})public User find(PathVariable(id)int id){​// 模拟数据返回return  new User(1001,李四,137526154875);}​​​​}​ 启动 provider8001 进行测试 看到以上 截图表示 成功 子模块 eureka-provider-8002 pom.xml dependencies!--增加 boot web的依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!--增加 eureka client 依赖--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactId/dependency!--增加 监控 boot 依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependency​!--引入 common-api module--dependencygroupIdcom.ly/groupIdartifactIdcloud-eureka-common-api/artifactIdversion1.0-SNAPSHOT/version/dependency​/dependencies application.yaml ​#设置端口号server:port: 8002​​​eureka:client:fetch-registry: true #是提供者,不是注册中心 ,可省略register-with-eureka: true #向注册中心 注册服务,可省略service-url: #服务地址defaultZone: http://localhost:7001/eurekaspring:application:name: provider-8002        # 设置应用名, 注意, 值 不允许使用 下划线​ 启动类 package com.ly;​import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.client.discovery.EnableDiscoveryClient;​SpringBootApplicationEnableDiscoveryClientpublic class EurekaProvider8002 {public static void main(String[] args) {SpringApplication.run(EurekaProvider8002.class,args);}}​ controller package com.ly.controller;​import com.ly.entity.OrderInfo;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RestController;​import java.time.LocalDateTime;​/*** provider8002 模拟就是 订单管理 模块*/RestControllerpublic class OrderInfoController {GetMapping(/order/{userId})public OrderInfo find(PathVariable(userId)int userId){//模拟数据返回return new OrderInfo(1003,保温杯,50,1, LocalDateTime.now(),1001);}}​ 启动 provider8002, 测试 7001 子模块 cloud-eureka-consumer-80 pom.xml dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdcom.ly/groupIdartifactIdcloud-eureka-common-api/artifactIdversion1.0-SNAPSHOT/version/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactId/dependency/dependencies 启动类 package com;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;SpringBootApplication EnableDiscoveryClient public class ConsumerApp80 {public static void main(String[] args) {SpringApplication.run(ConsumerApp80.class,args);} }配置文件 ​#设置端口号server:port: 80​​eureka:client:fetch-registry: true #是提供者,不是注册中心 ,可省略register-with-eureka: false #向注册中心 不注册服务,因此 是消费服务的service-url: #服务地址defaultZone: http://localhost:7001/eurekaspring:application:name: consumer80      # 设置应用名, 注意, 值 不允许使用 下划线​ 配置类 注入 RestTemplate package com;​​import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.web.client.RestTemplate;​/*** 配置类*/Configurationpublic class MyConfig {​Beanpublic RestTemplate restTemplate(){return new RestTemplate();}}​ controller package com.controller;​import com.ly.entity.OrderInfo;import com.ly.entity.User;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RestController;import org.springframework.web.client.RestTemplate;​RestControllerpublic class TestController {​Autowiredprivate RestTemplate restTemplate;​/*** 模拟查询 用户信息* param id* return*/GetMapping(/user/{id})public User queryUser(PathVariable(id)int id){//访问 8001 获得 数据return restTemplate.getForObject(http://localhost:8001/user/1,User.class);​}​/*** 模糊查询订单* param id* return*/GetMapping(/order/{id})public OrderInfo queryOrder(PathVariable(id)int id){//访问 8002 获得数据return restTemplate.getForObject(http://localhost:8002/order/3,OrderInfo.class);}​​}​ 启动 consumer 进行 测试
http://www.pierceye.com/news/902580/

相关文章:

  • 建立网站需要多少钱 索 圈湖南岚鸿新开传奇网站合击
  • 快手官方网站音乐人怎么做商城建站系统源码
  • 南充市建设厅官方网站高州做网站
  • 自建网站的优缺点wordpress题库制作
  • 哪家公司做网站毕业设计心理评测网站开发
  • 建设电影网站数据库脚本问答网站如何优化
  • 嘉峪关建设路小学网站游戏网页链接
  • 阿里云 网站根目录广东建筑企业50强
  • 河北省网络科技网站装饰设计素描
  • 合肥网站建设索q479185700企业做网站公司哪家好
  • wordpress暂停网站兰州网站建设方法
  • 丰台网站制作html教程 菜鸟教程
  • 在那个网站做直播好赚钱吗重庆妇科医院排名大全
  • 在线教育网站建设投标书查询公司的网站备案信息查询
  • 俄文网站策划wdcp wordpress
  • 建设个人网站流程中国工程建设招聘信息网站
  • 电影网站设计说明书在原域名给公司建立网站
  • 小规模公司做网站成本是什么wordpress主题转html
  • seo做的比较好的网站的几个特征app网站建设教程视频教程
  • 网站建设规范优质高等职业院校建设网站
  • 国内做网站哪家公司好机票什么网站建设
  • 万盛经开区建设局官方网站高校校园网站建设的要求
  • 制作企业网站的实训报告防伪码查询网站怎么做的
  • 做网站会很忙吗网站 js 广告代码
  • 没有网站域名备案专业做书画推广的网站
  • 做app网站公司名称有没有做黑市网站
  • apache建设网站做网站页面代码
  • html5 单页网站网络运维从入门到精通
  • 联合建设官方网站银川网站seo
  • jsp网站开发与设计摘要网站开发是什么