编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

SpringBoot学习笔记九之创建分布式工程

wxchong 2024-10-24 18:17:39 开源技术 7 ℃ 0 评论

先测试下本地环境

SpringBoot创建工程有两种方式:

  1. 创建Maven工程,引入SpringBoot环境
  2. 使用Spring插件创建工程,创建过程必须联网

填写信息

创建完成

在pom中加入依赖

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xlgl.wzy.spring.boot</groupId>
<artifactId>springboot-maven-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
 
<!-- 继承SpringBoot官方指定的父工程 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
 
<dependencies>
<!-- 加入Web开发所需要的场景启动器 -->
<dependency>
<!-- 指定groupId和artifactId即可,版本已在父工程中定义 -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
 
<!-- Maven构建过程相关配置 -->
<build>
<!-- 构建过程中所需要用到的插件 -->
<plugins>
<!-- 这个插件将SpringBoot应用打包成一个可执行的jar包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
 
</project>

创建主启动类

完成代码

写一个Web启动器Handler

代码

运行访问

安装Springboot插件

查看Eclipse版本的eclipse--help--About Eclipse,在Eclipseplatfrom那行的Version可以看到Eclipse版本号

spring官网下载地址:

https://spring.io/tools/sts/all

历史版本地址:

https://spring.io/tools/sts/legacy

在这个里面找我们的版本很不好找

所以一般网上找到的资料是到这里http://spring.io/tools/sts/all,然后就GG了

但是官网提供了一个下载地址:

http://download.springsource.com/release/TOOLS/update/3.9.5.RELEASE/e4.8/springsource-tool-suite-3.9.5.RELEASE-e4.8.0-updatesite.zip

可以对比拼接这个地址,找到我们想要的

eclipse4.7.0版本:

http://download.springsource.com/release/TOOLS/update/3.9.0.RELEASE/e4.7/springsource-tool-suite-3.9.0.RELEASE-e4.7.0-updatesite.zip

拼接好后,下载到本地

进入到 Eclipse --> Help--> Install new Sofware下

安装

安装重启即可,在view中出现下面的界面

就可以启动项目

访问,出现结果环境没有问题

将之前的项目扩展为分布式的

父工程learn-member-parent

注册中心learn-member-eureka

实体模块learn-member-entity

Mysql数据服务learn-member-mysql-provider

Redis数据服务learn-member-redis-provider

会员中心learn-member-authentication-cosumer

项目维护learn-member-project-cosume

订单维护learn-member-order-cosume

支付功能learn-member-pay-cosume

网关learn-member-zuul

接口learn-member-api

创建learn-member-reverse将之前的代码拿过来


创建learn-member-util 将之前的代码拿过来



所有项目

约定后续的包都作为com.xlgl.wzy的子包

主类都为MemberMainClass

所有项目的端口号设定

learn-member-parent

learn-member-eureka 1000

learn-member-entity

learn-member-mysql-provider 2000

learn-member-redis-provider 3000

learn-member-authentication-cosumer 4000

earn-member-project-cosume 5000

learn-member-order-cosume 7000

learn-member-pay-cosume 8000

learn-member-zuul 80

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表