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

专业的网站制作设计深圳电商网站制作

专业的网站制作设计,深圳电商网站制作,站点建立网站的方法,除了凡科建站还有什么网站吗一、创建步骤 模拟开发过程中的服务间关系。抽象出来#xff0c;开发中的微服务之间的关系是生产者和消费者关系。 总目标#xff1a;模拟一个最简单的服务调用场景#xff0c;场景中保护微服务提供者(Producer)和微服务调用者(Consumer)#xff0c;方便后面使用微服务架…一、创建步骤 模拟开发过程中的服务间关系。抽象出来开发中的微服务之间的关系是生产者和消费者关系。 总目标模拟一个最简单的服务调用场景场景中保护微服务提供者(Producer)和微服务调用者(Consumer)方便后面使用微服务架构 注意每个微服务为一个独立的SpringBoot工程。 1创建一个新的Maven父工程 2添加起步依赖坐标 !--创建SpringBoot的父工程-- parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.1.6.RELEASE/version /parent!--SpringBoot的依赖管理坐标-- dependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversionGreenwich.SR1/versiontypepom/typescopeimport/scope/dependency/dependencies /dependencyManagement二、在父工程下创建子模块 1.创建privider_service模块 目录结构 2.需要的依赖和配置文件application.yml 1依赖 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringCloud_parent/artifactIdgroupIdcom.william/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdprivider_service/artifactIdpropertiesmaven.compiler.source1.8/maven.compiler.sourcemaven.compiler.target1.8/maven.compiler.target/propertiesdependencies!--web的依赖了--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!--数据库的依赖--dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactId/dependency!--jpa依赖坐标--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-jpa/artifactId/dependency/dependencies/project2配置文件application.yml server:#服务的端口port: 9091 # DB 配置 spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/springcloud?useUnicodetruecharacterEncodingUTF-8serverTimezoneUTCpassword: rootusername: root3.数据库的准备 1 创建springcloud数据库 -- 创建数据库 CREATE database springcloud CHARACTER SET utf8 COLLATE utf8_general_ci;2创建tb_user用户表 -- 使用springcloud数据库 USE springcloud; -- ---------------------------- -- Table structure for tb_user -- ---------------------------- CREATE TABLE tb_user (id int(11) NOT NULL AUTO_INCREMENT,username varchar(100) DEFAULT NULL COMMENT 用户名,password varchar(100) DEFAULT NULL COMMENT 密码,name varchar(100) DEFAULT NULL COMMENT 姓名,age int(11) DEFAULT NULL COMMENT 年龄,sex int(11) DEFAULT NULL COMMENT 性别1男2女,birthday date DEFAULT NULL COMMENT 出生日期,created date DEFAULT NULL COMMENT 创建时间,updated date DEFAULT NULL COMMENT 更新时间,note varchar(1000) DEFAULT NULL COMMENT 备注,PRIMARY KEY (id) ) ENGINEInnoDB AUTO_INCREMENT2 DEFAULT CHARSETutf8 COMMENT用户信息表; -- ---------------------------- -- Records of tb_user -- ---------------------------- INSERT INTO tb_user VALUES (1, zhangsan, 123456, 张三, 13, 1, 2006-08-01, 2019-05-16, 2019-05-16, 张三); INSERT INTO tb_user VALUES (2, lisi, 123456, 李四, 13, 1, 2006-08-01, 2019-05-16, 2019-05-16, 李四);4.domain层 package com.itheima.domain;import javax.persistence.*; import java.util.Date;Entity Table(name tb_user) public class User {IdGeneratedValue(strategy GenerationType.IDENTITY)private Integer id;//主键idprivate String username;//用户名private String password;//密码private String name;//姓名private Integer age;//年龄private Integer sex;//性别 1男性2女性private Date birthday; //出生日期private Date created; //创建时间private Date updated; //更新时间private String note;//备注Overridepublic String toString() {return User{ id id , username username \ , password password \ , name name \ , age age , sex sex , birthday birthday , created created , updated updated , note note \ };}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public String getUsername() {return username;}public void setUsername(String username) {this.username username;}public String getPassword() {return password;}public void setPassword(String password) {this.password password;}public String getName() {return name;}public void setName(String name) {this.name name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age age;}public Integer getSex() {return sex;}public void setSex(Integer sex) {this.sex sex;}public Date getBirthday() {return birthday;}public void setBirthday(Date birthday) {this.birthday birthday;}public Date getCreated() {return created;}public void setCreated(Date created) {this.created created;}public Date getUpdated() {return updated;}public void setUpdated(Date updated) {this.updated updated;}public String getNote() {return note;}public void setNote(String note) {this.note note;} } 5.controller层 package com.william.Controller;import com.william.domain.User; import com.william.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;/*** author lijunxuan* date Created in 2019/6/29 10:09* description * version: 1.0*/ RestController RequestMapping(/user) public class UserController {AutowiredUserService userService;RequestMapping(findById)public User findById(Integer id){return userService.findById(id);}} 6.service层 1UserService接口 package com.william.service;import com.william.domain.User;public interface UserService {User findById(Integer id);} 2UserServiceImpl实现类 package com.william.service.Impl;import com.william.Dao.UserDao; import com.william.domain.User; import com.william.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;import java.util.Optional;/*** author lijunxuan* date Created in 2019/6/29 10:24* description * version: 1.0*/ Service public class UserServiceImpl implements UserService {AutowiredUserDao userDao;Overridepublic User findById(Integer id) {OptionalUser userfindById userDao.findById(id);return userfindById.get();} } 7.Dao层 package com.william.Dao;import com.william.domain.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository;Repository public interface UserDao extends JpaRepositoryUser,Integer { } 8.ProviderServiceApplication package com.william;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;/*** author lijunxuan* date Created in 2019/6/29 10:34* description * version: 1.0*/ SpringBootApplication public class ProviderServiceApplication {public static void main(String[] args) {SpringApplication.run(ProviderServiceApplication.class,args);} } 9.测试结果 2.consumer_service 1创建过程 2导入依赖和目录结构 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringCloud_parent/artifactIdgroupIdcom.william/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdconsumer_service/artifactIdpropertiesmaven.compiler.source1.8/maven.compiler.sourcemaven.compiler.target1.8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!--热部署依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-devtools/artifactId/dependency/dependencies/project3application.yml server:port: 80804DemoApplication package com.william;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestTemplate;/*** author lijunxuan* date Created in 2019/6/29 9:53* description * version: 1.0*/ SpringBootApplication public class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class,args);}//RestTemplate注入SPring容器当中Beanpublic RestTemplate restTemplate(){return new RestTemplate();} } 5ConsumerController package com.william.controller;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate;/*** author lijunxuan* date Created in 2019/6/29 9:54* description * version: 1.0*/ RestController RequestMapping(/consumer) public class ConsumerController {AutowiredRestTemplate restTemplate;RequestMapping(/findUser)public String findUser(Integer id){//请求服务提供者的查询用户详情地址// String urlhttp://localhost:9091/user/findById?idid;altenter 找到formatString url String.format(http://localhost:9091/user/findById?id%d, id);return restTemplate.getForObject(url,String.class);}} 6测试结果
http://wiki.neutronadmin.com/news/297218/

相关文章:

  • 揭秘低价网站建设危害仿网站源码是怎么弄的
  • 高端网站制作多少钱优秀的浏览器主页
  • 速卖通网站怎样做店面的二维码自己做的网站怎么发布到网上
  • 三大框架网站开发网页qq登录保护不让用
  • 深圳网站开发公司h5wordpress时区设置
  • 外卖网站建设方案书昆山市网站建设
  • flask做网站工具重庆网站制作设计获客
  • 定制网站哪个好白和黑人做网站
  • 网页设计结课报告关键词优化seo多少钱一年
  • 购物网站建设代码编程需要下载什么软件
  • 如何搭建一个网站安卓版傻瓜式编程app软件
  • 丽水网站开发制作返利网站
  • 拍卖网站模版网站图片设置教程
  • ui设计师网站python做网站有什么弊端
  • 获客平台有哪些seo网站优化经理
  • 网站的数据库怎么做网站搜索优化技巧
  • 钦州网站建建一个网站一般要多少钱
  • 长春 餐饮 网站建设好的app设计网站
  • 网站被k的表现做网站上极海网
  • 重庆秀山网站建设公司网站代运营公司
  • 有哪些做网站的公司好佛山电商网站制作
  • 那些网站分享pr做的视频软件东莞建设培训中心网站
  • 网站建设龙卡要审批多久时间云电脑永久免费版手机版
  • 早教类网站模板去掉wordpress 上一篇
  • 怎么用vs做网站网站建设续费是什么费用
  • 网站建设内容和功能的介绍怎么在工商网站做实名认证
  • 新闻类网站设计wordpress如何在数据库中修改域名
  • 有哪些做短租的网站好口碑好网站制作公司哪家好
  • 企业网站的优化和推广方法建立网站专栏
  • 关于做网站的外语文献抖音搜索排名