在eclipse中使用maven構建spring cloud微服務

工具/原料

  • eclipse
  • maven
  • spring boot
  • spring cloud

1.新建一個maven項目html

2.文件-》新建-》項目spring

3.選擇Maven project,而後點擊下一步apache

4.再點擊下一步eclipse

5.選擇maven-archetype-quicktypemaven

6.輸入group id, artifact id等信息,點擊完成spring-boot

7.項目結構如圖工具

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

 

<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>

 

9.編寫Application程序

 

package com.gwolf.mircoclouds;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class Application {

    public static void main(String[] args) {

        SpringApplication.run(Application.class, args);

    }

}

10.執行Application程序,若是沒有錯誤輸出說明spring boot已經搭建成功了。url

11.spring cloud須要瞭解spring boot的知識,咱們會寫相關方面的文章介紹spring bootspa

 

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

相關文章
相關標籤/搜索