server:
port: 8761 #服务器端口
eureka:
instance:
hostname: eureka-server #eureka实例的主机名
client:
register-with-eureka: false #不把自己(eureka-server)注册到eureka上(不做高可用的情况下)
fetch-registry: false #不从eureka上来获取服务的注册信息(因为本身就是注册中心,消费者就需要获取提供者的信息)
service-url:
defaultZone: http://localhost:8761/eureka/ #不指定默认为http://localhost:8761/eureka.client/
<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-netflix-eureka-serverartifactId>
<exclusions>
<exclusion>
<artifactId>woodstox-coreartifactId>
<groupId>com.fasterxml.woodstoxgroupId>
exclusion>
<exclusion>
<artifactId>jsr305artifactId>
<groupId>com.google.code.findbugsgroupId>
exclusion>
<exclusion>
<artifactId>HdrHistogramartifactId>
<groupId>org.hdrhistogramgroupId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-testartifactId>
<scope>testscope>
<exclusions>
<exclusion>
<groupId>org.junit.vintagegroupId>
<artifactId>junit-vintage-engineartifactId>
exclusion>
exclusions>
dependency>
dependencies>
启动项目后,控制台:(正常启动,没报错)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.0.RELEASE)
2020-05-30 20:35:27.633 INFO 98337 --- [ main] c.a.e.EurekaServerApplication : No active profile set, falling back to default profiles: default
2020-05-30 20:35:28.652 WARN 98337 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2020-05-30 20:35:28.813 INFO 98337 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=eb24c9f6-b729-33b9-9f69-7305cd06e02b
2020-05-30 20:35:29.154 INFO 98337 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2020-05-30 20:35:29.163 INFO 98337 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-30 20:35:29.163 INFO 98337 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-05-30 20:35:29.271 INFO 98337 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-30 20:35:29.271 INFO 98337 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1614 ms
2020-05-30 20:35:29.370 WARN 98337 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-05-30 20:35:29.371 INFO 98337 --- [ 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.
2020-05-30 20:35:29.386 INFO 98337 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@56f521c6
2020-05-30 20:35:29.779 INFO 98337 --- [ main] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2020-05-30 20:35:29.855 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2020-05-30 20:35:29.856 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2020-05-30 20:35:29.980 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2020-05-30 20:35:29.980 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2020-05-30 20:35:30.477 WARN 98337 --- [ main] o.s.c.n.a.ArchaiusAutoConfiguration : No spring.application.name found, defaulting to 'application'
2020-05-30 20:35:30.477 WARN 98337 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-05-30 20:35:30.478 INFO 98337 --- [ 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.
2020-05-30 20:35:30.636 INFO 98337 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-30 20:35:31.153 WARN 98337 --- [ main] ockingLoadBalancerClientRibbonWarnLogger : You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of `spring.cloud.loadbalancer.ribbon.enabled` to `false` or remove spring-cloud-starter-netflix-ribbon from your project.
2020-05-30 20:35:31.199 INFO 98337 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2020-05-30 20:35:31.221 INFO 98337 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2020-05-30 20:35:31.221 INFO 98337 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2020-05-30 20:35:31.226 INFO 98337 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1590842131225 with initial instances count: 0
2020-05-30 20:35:31.257 INFO 98337 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...
2020-05-30 20:35:31.259 INFO 98337 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://localhost:8761/eureka/]
2020-05-30 20:35:31.467 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2020-05-30 20:35:31.467 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2020-05-30 20:35:31.467 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2020-05-30 20:35:31.467 INFO 98337 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2020-05-30 20:35:36.591 INFO 98337 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://localhost:8761/eureka/
2020-05-30 20:35:36.603 INFO 98337 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []
2020-05-30 20:35:36.604 INFO 98337 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized
2020-05-30 20:35:36.620 INFO 98337 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2020-05-30 20:35:36.710 INFO 98337 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application UNKNOWN with eureka with status UP
2020-05-30 20:35:36.713 INFO 98337 --- [ Thread-438] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..
2020-05-30 20:35:36.714 INFO 98337 --- [ Thread-438] o.s.c.n.e.server.EurekaServerBootstrap : Eureka data center value eureka.datacenter is not set, defaulting to default
2020-05-30 20:35:36.714 INFO 98337 --- [ Thread-438] o.s.c.n.e.server.EurekaServerBootstrap : Eureka environment value eureka.environment is not set, defaulting to test
2020-05-30 20:35:36.730 INFO 98337 --- [ Thread-438] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false
2020-05-30 20:35:36.731 INFO 98337 --- [ Thread-438] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context
2020-05-30 20:35:36.731 INFO 98337 --- [ Thread-438] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2020-05-30 20:35:36.731 INFO 98337 --- [ Thread-438] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2020-05-30 20:35:36.731 INFO 98337 --- [ Thread-438] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2020-05-30 20:35:36.747 INFO 98337 --- [ Thread-438] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2020-05-30 20:35:36.773 INFO 98337 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2020-05-30 20:35:36.774 INFO 98337 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2020-05-30 20:35:36.812 INFO 98337 --- [ main] c.a.e.EurekaServerApplication : Started EurekaServerApplication in 20.996 seconds (JVM running for 26.947)
2020-05-30 20:35:37.190 INFO 98337 --- [)-192.168.0.106] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-30 20:35:37.191 INFO 98337 --- [)-192.168.0.106] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-05-30 20:35:37.203 INFO 98337 --- [)-192.168.0.106] o.s.web.servlet.DispatcherServlet : Completed initialization in 12 ms
2020-05-30 20:36:36.737 INFO 98337 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2020-05-30 20:37:36.742 INFO 98337 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 3ms
2020-05-30 20:38:36.749 INFO 98337 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 4ms
2020-05-30 20:39:36.754 INFO 98337 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 3ms
2020-05-30 20:40:36.761 INFO 98337 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 5ms
2020-05-30 20:41:36.768 INFO 98337 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 5ms
访问http://localhost:8761/eureka/
(404错误)
解决办法: 去掉eureka/
,直接访问http://localhost:8761/
如果还不行,在application.yml里添加spring.freemarker.prefer-file-system-access: false
试试看。