Spring Cloud构建微服务架构(一)——服务注册与发现

This commit is contained in:
程序猿DD
2016-05-31 21:56:19 +08:00
parent 469798e649
commit 7da6df8061
4 changed files with 26 additions and 37 deletions
+18 -20
View File
@@ -12,9 +12,10 @@
<description>Spring Cloud project</description> <description>Spring Cloud project</description>
<parent> <parent>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-cloud-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RELEASE</version> <version>1.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<properties> <properties>
@@ -24,8 +25,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-cloud-starter-eureka</artifactId>
</dependency> </dependency>
<dependency> <dependency>
@@ -34,23 +35,20 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
</dependencies> </dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@@ -4,8 +4,8 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient
@SpringBootApplication
public class ComputeServiceApplication { public class ComputeServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {
@@ -0,0 +1,6 @@
spring.application.name=compute-service
server.port=2222
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
@@ -1,15 +0,0 @@
# Spring properties
spring:
application:
name: compute-service
# HTTP Server
server:
port: 2222 # HTTP (Tomcat) port
# Discovery Server Access
eureka:
client:
serviceUrl:
defaultZone: http://localhost:1111/eureka/