时间: 2020-09-10|24次围观|0 条评论

工具/原料

  • eclipse
  • maven
  • spring boot
  • spring cloud

1.新建一个maven项目

2.文件-》新建-》项目

在eclipse中使用maven构建spring cloud微服务插图

3.选择Maven project,然后点击下一步

在eclipse中使用maven构建spring cloud微服务插图1

4.再点击下一步

在eclipse中使用maven构建spring cloud微服务插图2

5.选择maven-archetype-quicktype

在eclipse中使用maven构建spring cloud微服务插图3

6.输入group id, artifact id等信息,点击完成

在eclipse中使用maven构建spring cloud微服务插图4

7.项目结构如图

在eclipse中使用maven构建spring cloud微服务插图5

8.在pom文件中增加spring cloud配置:

 

<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.gwolf</groupId>  <artifactId>mircoclouds</artifactId>  <version>0.0.1-SNAPSHOT</version>  <packaging>jar</packaging>  <name>mircoclouds</name>  <url>http://maven.apache.org</url>  <properties>    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  </properties>  <parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>1.5.6.RELEASE</version></parent><dependencyManagement>    <dependencies>        <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-dependencies</artifactId>            <version>Dalston.SR4</version>            <type>pom</type>            <scope>import</scope>        </dependency>    </dependencies></dependencyManagement><dependencies><dependency>    <groupId>org.springframework.cloud</groupId>    <artifactId>spring-cloud-starter-config</artifactId></dependency><dependency>    <groupId>org.springframework.cloud</groupId>    <artifactId>spring-cloud-starter-eureka</artifactId></dependency></dependencies></project>

 

在eclipse中使用maven构建spring cloud微服务插图6在eclipse中使用maven构建spring cloud微服务插图7在eclipse中使用maven构建spring cloud微服务插图8
9.编写Application程序

 

package com.gwolf.mircoclouds;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class Application {    public static void main(String[] args) {        SpringApplication.run(Application.class, args);    }}

在eclipse中使用maven构建spring cloud微服务插图9

10.执行Application程序,如果没有错误输出说明spring boot已经搭建成功了。

在eclipse中使用maven构建spring cloud微服务插图10

11.spring cloud需要了解spring boot的知识,我们会写相关方面的文章介绍spring boot

 

原文链接:https://jingyan.baidu.com/article/91f5db1b1c7ebf1c7e05e374.html

文章转载于:https://www.cnblogs.com/jiafeimao-dabai/p/11725983.html

原著是一个有趣的人,若有侵权,请通知删除

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《在eclipse中使用maven构建spring cloud微服务
   

还没有人抢沙发呢~