zoukankan      html  css  js  c++  java
  • 【SpringCloud】极简SpringCloudServer工程

    本例基于SpringBoot 2.5.5,不保证其它版本的适用性。

    例程:https://files.cnblogs.com/files/heyang78/simpleSpringCloudServer_210926.rar

    重要设置:

    pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.5.5</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.example</groupId>
        <artifactId>demo-1</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>demo-1</name>
        <description>Demo project for Spring Boot</description>
        <properties>
            <java.version>11</java.version>
            <spring-cloud.version>2020.0.4</spring-cloud.version>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>

    <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-function-context</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency>

    </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>

    配置文件:

    spring.application.name=erkserver
    eureka.client.register-with-eureka=false
    eureka.client.fetch-registry=false

    启动类:

    package com.example.demo;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @SpringBootApplication
    @EnableEurekaServer
    public class Demo1Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Demo1Application.class, args);
        }
    
    }

    启动后在http://localhost:8080/的效果:

     这个工程可以作为SpringCloud的起始工程。

    END

  • 相关阅读:
    带参的方法
    类的无参方法
    类和对象
    关于线程间的通信的几个解决事例
    一个简单的邮件发送
    关于process
    关于java的static语句块
    关于struts2拦截器获取页面参数
    hexo github pages 首页不展示,出现代码怎么办
    使用Hexo搭建个人博客(三)
  • 原文地址:https://www.cnblogs.com/heyang78/p/15337471.html
Copyright © 2011-2022 走看看