Spring Cloud
Spring Cloud是一个分布式的整体解决方案。Spring Cloud 为开发者提供了在分布式系统(配 置管理,服务发现,熔断,路由,微代理,控制总线,一次性token,全局琐,leader选举,分 布式session,集群状态)中快速构建的工具,使用Spring Cloud的开发者可以快速的启动服务 或构建应用、同时能够快速和云平台资源进行对接
SpringCloud分布式开发五大常用组件
•服务发现——Netflix Eureka
• 客服端负载均衡——Netflix Ribbon
• 断路器——Netflix Hystrix
• 服务网关——Netflix Zuul
• 分布式配置——Spring Cloud Config
Spring Cloud 入门
1、工程项目搭建
步骤:
创建一个注册中心Eurka-server工程
工程目录如下:
接着 ,我们再创建服务提供者一个工程provider-ticket
再创建一个服务消费者工程consumer-user
已经创建的工程项目如下:
2、首先,我们需要对以下工程代码的编写
先配置,注册中心(eureka-server)工程,的全局文件
application.yml
server:
port: 8761
eureka:
instance:
hostname: euruka-server # eureka实例主机名
client:
register-with-eureka: false #不把自己注册到eureka上
fetch-registry: false #不从eureka上来获取服务的注册信息
service-url:
defaultZone: http://localhost:8761/eureka/
接着,我们可以在注册中心(eureka-server)工程主程序类启动程序,注意的是,在启动主程序之前需要加一个注解:@EnableEurekaServer
启动主程序,控制台日志打印的信息
访问:localhost:8761
二、服务注册
1、我们需要先在服务提供者provider-ticket工程下applicatio.yml做全局配置文件
applicatio.yml
server:
port: 8001
spring:
application:
name: provider-ticket
eureka:
instance:
prefer-ip-address: true # 注册服务的时候使用服务的ip地址
client:
service-url:
defaultZone: http://localhost:8761/eureka/
接着,我们在java目录下,创建一个service层和controller层的代码的编写。
service层下,创建一个TicketService类
TicketService.java
package com.study.providerticket.service;
import org.springframework.stereotype.Service;
@Service
public class TicketService {
public String getTicket(){
return "《厉害了,我的国》";
}
}
controller层下,创建一个TicketController类
TicketController.java
package com.study.providerticket.controller;
import com.study.providerticket.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TicketController {
@Autowired
TicketService ticketService;
@GetMapping("/ticket")
public String getTicket(){
return ticketService.getTicket();
}
}
启动provider-ticket工程的主程序,控制台日志打印的信息
访问:http://localhost:8001/ticket
无法访问,排查了一下,在pom文件少了一个spring-boot-starter-web文件,引入一个依赖即可
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
重新启动provider-ticket工程的主程序
再次访问:http://localhost:8001/ticket
在注册中心页面,8001就不注册进来了
打包
打包完成后,就可以拿到jar包
拷贝出来了,标注8001的服务提供者
打包8002服务提供者
当我们同时启动多个服务提供者工程的程序,可以采用cmd命令操作:java -jar 文件名
win环境启动8001的程序工程:
C:\Users\HP\Desktop\package-jar>java -jar provider-ticket-0.0.1-SNAPSHOT8001.jar
控制台日志打印8001的信息:
2019-11-10 10:40:45.759 INFO 11848 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$1e9646aa] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.10.RELEASE)
2019-11-10 10:40:46.886 INFO 11848 --- [ main] c.s.p.ProviderTicketApplication : No active profile set, falling back to default profiles: default
2019-11-10 10:40:47.831 INFO 11848 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=aabaf3ae-1a5e-39f9-8d3d-bd57008705ef
2019-11-10 10:40:47.990 INFO 11848 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$1e9646aa] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-11-10 10:40:49.097 INFO 11848 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8001 (http)
2019-11-10 10:40:49.136 INFO 11848 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-11-10 10:40:49.137 INFO 11848 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-10 10:40:49.338 INFO 11848 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-11-10 10:40:49.342 INFO 11848 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2430 ms
2019-11-10 10:40:49.484 WARN 11848 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-11-10 10:40:49.485 INFO 11848 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-11-10 10:40:49.499 WARN 11848 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-11-10 10:40:49.499 INFO 11848 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-11-10 10:40:49.901 INFO 11848 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-10 10:40:52.474 INFO 11848 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-11-10 10:40:52.557 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-11-10 10:40:52.826 INFO 11848 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-11-10 10:40:52.827 INFO 11848 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-11-10 10:40:53.014 INFO 11848 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-11-10 10:40:53.014 INFO 11848 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-11-10 10:40:53.326 INFO 11848 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2019-11-10 10:40:53.960 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-11-10 10:40:53.961 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-11-10 10:40:53.965 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-11-10 10:40:53.969 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-11-10 10:40:53.971 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-11-10 10:40:53.975 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2019-11-10 10:40:53.976 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-11-10 10:40:54.248 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2019-11-10 10:40:54.257 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2019-11-10 10:40:54.262 INFO 11848 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-11-10 10:40:54.270 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1573353654268 with initial instances count: 1
2019-11-10 10:40:54.277 INFO 11848 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application PROVIDER-TICKET with eureka with status UP
2019-11-10 10:40:54.279 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1573353654279, current=UP, previous=STARTING]
2019-11-10 10:40:54.285 INFO 11848 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-TICKET/DESKTOP-EVJGASP:provider-ticket:8001: registering service...
2019-11-10 10:40:54.332 ERROR 11848 --- [ main] org.apache.catalina.util.LifecycleBase : Failed to start component [Connector[HTTP/1.1-8001]]
org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1008) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) [tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:263) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:195) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:297) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) [spring-context-5.1.11.RELEASE.jar!/:5.1.11.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
at com.study.providerticket.ProviderTicketApplication.main(ProviderTicketApplication.java:13) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_40]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_40]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_40]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_40]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [provider-ticket-0.0.1-SNAPSHOT8001.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [provider-ticket-0.0.1-SNAPSHOT8001.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [provider-ticket-0.0.1-SNAPSHOT8001.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [provider-ticket-0.0.1-SNAPSHOT8001.jar:0.0.1-SNAPSHOT]
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_40]
at sun.nio.ch.Net.bind(Net.java:437) ~[na:1.8.0_40]
at sun.nio.ch.Net.bind(Net.java:429) ~[na:1.8.0_40]
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_40]
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_40]
at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:230) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:213) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1124) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1210) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:586) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1005) ~[tomcat-embed-core-9.0.27.jar!/:9.0.27]
... 22 common frames omitted
2019-11-10 10:40:54.348 INFO 11848 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-11-10 10:40:54.352 INFO 11848 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-TICKET/DESKTOP-EVJGASP:provider-ticket:8001 - registration status: 204
2019-11-10 10:40:54.364 INFO 11848 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-11-10 10:40:54.366 INFO 11848 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application PROVIDER-TICKET with eureka with status DOWN
2019-11-10 10:40:54.367 WARN 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1573353654367, current=DOWN, previous=UP]
2019-11-10 10:40:54.368 INFO 11848 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-TICKET/DESKTOP-EVJGASP:provider-ticket:8001: registering service...
2019-11-10 10:40:54.377 INFO 11848 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2019-11-10 10:40:54.382 INFO 11848 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-TICKET/DESKTOP-EVJGASP:provider-ticket:8001 - registration status: 204
2019-11-10 10:40:54.387 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2019-11-10 10:40:57.395 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Unregistering ...
2019-11-10 10:40:57.413 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-TICKET/DESKTOP-EVJGASP:provider-ticket:8001 - deregister status: 200
2019-11-10 10:40:57.436 INFO 11848 --- [ main] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2019-11-10 10:40:57.445 ERROR 11848 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8001 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8001, or configure this application to listen on another port.
win环境启动8002的程序工程:
C:\Users\HP\Desktop\package-jar>java -jar provider-ticket-0.0.1-SNAPSHOT8002.jar
控制台日志打印8002的信息:
2019-11-10 10:41:19.555 INFO 28288 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fc09ca35] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.10.RELEASE)
2019-11-10 10:41:20.667 INFO 28288 --- [ main] c.s.p.ProviderTicketApplication : No active profile set, falling back to default profiles: default
2019-11-10 10:41:21.576 INFO 28288 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=aabaf3ae-1a5e-39f9-8d3d-bd57008705ef
2019-11-10 10:41:21.717 INFO 28288 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fc09ca35] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-11-10 10:41:22.805 INFO 28288 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8002 (http)
2019-11-10 10:41:22.857 INFO 28288 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-11-10 10:41:22.858 INFO 28288 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-10 10:41:23.073 INFO 28288 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-11-10 10:41:23.074 INFO 28288 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2385 ms
2019-11-10 10:41:23.228 WARN 28288 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-11-10 10:41:23.229 INFO 28288 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-11-10 10:41:23.246 WARN 28288 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-11-10 10:41:23.246 INFO 28288 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-11-10 10:41:23.667 INFO 28288 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-10 10:41:26.650 INFO 28288 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-11-10 10:41:26.755 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-11-10 10:41:27.072 INFO 28288 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-11-10 10:41:27.072 INFO 28288 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-11-10 10:41:27.266 INFO 28288 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-11-10 10:41:27.266 INFO 28288 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-11-10 10:41:27.772 INFO 28288 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2019-11-10 10:41:28.484 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-11-10 10:41:28.485 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-11-10 10:41:28.493 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-11-10 10:41:28.494 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-11-10 10:41:28.495 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-11-10 10:41:28.499 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2019-11-10 10:41:28.504 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-11-10 10:41:28.715 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2019-11-10 10:41:28.719 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2019-11-10 10:41:28.725 INFO 28288 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-11-10 10:41:28.730 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1573353688729 with initial instances count: 0
2019-11-10 10:41:28.732 INFO 28288 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application PROVIDER-TICKET with eureka with status UP
2019-11-10 10:41:28.735 INFO 28288 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1573353688735, current=UP, previous=STARTING]
2019-11-10 10:41:28.740 INFO 28288 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-TICKET/DESKTOP-EVJGASP:provider-ticket:8002: registering service...
2019-11-10 10:41:28.853 INFO 28288 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8002 (http) with context path ''
2019-11-10 10:41:28.857 INFO 28288 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8002
2019-11-10 10:41:28.895 INFO 28288 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-TICKET/DESKTOP-EVJGASP:provider-ticket:8002 - registration status: 204
2019-11-10 10:41:29.868 INFO 28288 --- [ main] c.s.p.ProviderTicketApplication : Started ProviderTicketApplication in 12.597 seconds (JVM running for 13.33)
2019-11-10 10:41:58.723 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-11-10 10:41:58.726 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-11-10 10:41:58.746 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-11-10 10:41:58.747 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-11-10 10:41:58.749 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-11-10 10:41:58.753 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: false
2019-11-10 10:41:58.756 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-11-10 10:41:58.809 INFO 28288 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 200
2019-11-10 10:46:28.510 INFO 28288 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
接着,在注册中心页面刷新将会看到两个端口号已经被注册进来了!