栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

十分钟创建服务发现项目

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

十分钟创建服务发现项目

pom.xml: 留意spring-boot和spring-cloud的版本号需要一致,如Hoxton SR5后的spring-boot版本需为2.3.x,如果版本不一致,会发生很多意想不到的问题。如找不到@EnableEurekaServer注解所在包,尽管对应的包已经导入到maven中。



    4.0.0
    com.xxx
    eureka-study
    0.0.1-SNAPSHOT
    eureka-server
    Demo project for Spring Boot

    
        1.8
        UTF-8
        UTF-8
        2.3.1.RELEASE
        Hoxton.SR12
    

    
        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
        
        
	        org.springframework.cloud
	        spring-cloud-starter-netflix-eureka-server
	    
	    
    

    
        
            
                org.springframework.boot
                spring-boot-dependencies
                ${spring-boot.version}
                pom
                import
            
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            
            
        
    




EurekaServerApplication.java:

package com.xxx;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }

}

application.properties:

# 
spring.application.name=eureka-server
server.port=1001

eureka.instance.hostname=localhost
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false


启动spring-boot项目,访问1001端口即可。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/891029.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号