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


使用eclipse中使用maven構建spring cloud微服務,springcloud通過maven構建項目。springcloud項目搭建。

工具/原料

 
  • eclipse
  • maven
  • spring boot
  • spring cloud

方法/步驟

 
  1.  

    新建一個maven項目

  2.  

    文件-》新建-》項目

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

    選擇Maven project,然后點擊下一步

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

    再點擊下一步

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

    選擇maven-archetype-quicktype

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

    輸入group id, artifact id等信息,點擊完成

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

    項目結構如圖

    在eclipse中使用maven構建spring cloud微服務
  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>mircocloud</artifactId>

      <version>0.0.1-SNAPSHOT</version>

      <packaging>jar</packaging>

     

      <name>mircocloud</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微服務
    在eclipse中使用maven構建spring cloud微服務
    在eclipse中使用maven構建spring cloud微服務
  9.  

    編寫Application程序

     

    @SpringBootApplication

    public class Application {

    public static void main(String[] args) {

    SpringApplication.run(Application.class, args);

    }

    }

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

    執行Application程序,如果沒有錯誤輸出說明spring boot已經搭建成功了。

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

    spring cloud需要了解spring boot的知識,我們會寫相關方面的文章介紹spring boot

    END

注意事項

 
  • 需要提前熟悉spring boot的用法


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM