diff --git b/.gitignore a/.gitignore new file mode 100644 index 0000000..153c933 --- /dev/null +++ a/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git b/pom.xml a/pom.xml new file mode 100644 index 0000000..4b8bb79 --- /dev/null +++ a/pom.xml @@ -0,0 +1,59 @@ +<?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 http://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.1.3.RELEASE</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>com.tianbo</groupId> + <artifactId>cloud</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>cloud</name> + <description>Demo project for Spring Boot</description> + + <properties> + <java.version>1.8</java.version> + <spring-cloud.version>Greenwich.BUILD-SNAPSHOT</spring-cloud.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </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> diff --git b/readMe.md a/readMe.md new file mode 100644 index 0000000..861808e --- /dev/null +++ a/readMe.md @@ -0,0 +1 @@ +# eureka 注册中心 diff --git b/src/main/java/com/tianbo/cloud/CloudApplication.java a/src/main/java/com/tianbo/cloud/CloudApplication.java new file mode 100644 index 0000000..c022728 --- /dev/null +++ a/src/main/java/com/tianbo/cloud/CloudApplication.java @@ -0,0 +1,15 @@ +package com.tianbo.cloud; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; + +@SpringBootApplication +@EnableEurekaServer +public class CloudApplication { + + public static void main(String[] args) { + SpringApplication.run(CloudApplication.class, args); + } + +} diff --git b/src/main/resources/application.properties a/src/main/resources/application.properties new file mode 100644 index 0000000..b39439c --- /dev/null +++ a/src/main/resources/application.properties @@ -0,0 +1,24 @@ + +#服务端口 +server.port=19527 +server.servlet.context-path=${SERVER_CONTEXTPATH:} + +#服务名 +spring.application.name=eukekaCenter + + +#springcloud 注册中心服务配置 +eureka.instance.hostname=${spring.cloud.client.ip-address} +eureka.instance.prefer-ip-address=true +eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${server.port} + +#表示是否将自己注册到Eureka Server,默认为true。由于当前应用就是Eureka Server,故而设置为false。 +eureka.client.register-with-eureka=false +#表示是否从Eureka Server获取注册信息,默认为true。因为这是一个单点的Eureka Server,不需要同步其他的Eureka Server节点的数据,故而设置为false。 +eureka.client.fetch-registry=false +#eureka注册中心服务器地址,设置与Eureka Server交互的地址,查询服务和注册服务都需要依赖这个地址,多个地址可用逗号(英文的)分割。 +eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/ + +#配置注册中心清理无效节点的时间间隔,默认60000毫秒,即60秒。 +eureka.server.eviction-interval-timer-in-ms=5000 +eureka.server.enable-self-preservation=false \ No newline at end of file diff --git b/src/test/java/com/tianbo/cloud/CloudApplicationTests.java a/src/test/java/com/tianbo/cloud/CloudApplicationTests.java new file mode 100644 index 0000000..eea211e --- /dev/null +++ a/src/test/java/com/tianbo/cloud/CloudApplicationTests.java @@ -0,0 +1,16 @@ +package com.tianbo.cloud; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class CloudApplicationTests { + + @Test + public void contextLoads() { + } + +}