本机IP为  192.168.1.102

 

1.   新建Maven项目   eureka

 

2.   pom.xml

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

4.0.0

com.java

eureka

1.0.0-SNAPSHOT

${project.artifactId}

1.8

org.springframework.boot

spring-boot-starter-parent

2.0.5.RELEASE

org.springframework.boot

spring-boot-starter-web

org.springframework.cloud

spring-cloud-starter-netflix-eureka-server

2.0.0.RELEASE

org.springframework

springloaded

1.2.8.RELEASE

org.springframework.boot

spring-boot-devtools

${project.artifactId}

org.apache.maven.plugins

maven-compiler-plugin

${jdk.version}

${jdk.version}

UTF-8

org.springframework.boot

spring-boot-maven-plugin

repackage

 

 

3.   application.yml

server:

port: 8080

eureka:

instance:

hostname: 192.168.1.102

client:

register-with-eureka: false

fetch-registry: false

service-url:

defaultZone: http://192.168.1.102:8080/eureka/

 

 

4.   EurekaStarter.java

package com.java.eureka;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer

@SpringBootApplication

public class EurekaStarter extends SpringBootServletInitializer {

public static void main(String[] args) {

SpringApplication.run(EurekaStarter.class, args);

}

@Override

protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

return builder.sources(EurekaStarter.class);

}

}

 

 

 5. 启动测试

运行EurekaStarter.java

浏览器输入URL

http://127.0.0.1:8080/

 

 

本机IP为  192.168.1.102

也可以输入    

http://192.168.1.102:8080/

访问

 

推荐阅读

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。
大家都在看: