SpringCloud啟動eureka server后,沒報錯卻不能訪問管理頁面(404問題)
SpringCloud啟動eureka server,沒報錯卻不能訪問管理頁面

application.yml:
server:
port: 8761 #服務(wù)器端口
eureka:
instance:
hostname: eureka-server #eureka實例的主機名
client:
register-with-eureka: false #不把自己(eureka-server)注冊到eureka上(不做高可用的情況下)
fetch-registry: false #不從eureka上來獲取服務(wù)的注冊信息(因為本身就是注冊中心,消費者就需要獲取提供者的信息)
service-url:
defaultZone: http://localhost:8761/eureka/ #不指定默認為http://localhost:8761/eureka.client/
主配置類:

pom.xml
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> <exclusions> <exclusion> <artifactId>woodstox-core</artifactId> <groupId>com.fasterxml.woodstox</groupId> </exclusion> <exclusion> <artifactId>jsr305</artifactId> <groupId>com.google.code.findbugs</groupId> </exclusion> <exclusion> <artifactId>HdrHistogram</artifactId> <groupId>org.hdrhistogram</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </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
試試看。
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Java使用Apache POI庫讀取Excel表格文檔的示例
POI庫是Apache提供的用于在Windows下讀寫各類微軟Office文檔的Java庫,這里我們就來看一下Java使用Apache POI庫讀取Excel表格文檔的示例:2016-06-06
Redisson分布式信號量RSemaphore的使用超詳細講解
這篇文章主要介紹了Redisson分布式信號量RSemaphore的使用,基于Redis的Redisson的分布式信號量RSemaphore采用了與java.util.concurrent.Semaphore相似的接口和用法2023-02-02
SpringBoot3集成MapstructPlus的實現(xiàn)
本文主要介紹了SpringBoot3集成MapstructPlus的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2025-08-08
基于SpringBoot+Avue實現(xiàn)短信通知功能
Avue是基于vue和element-ui的快速開發(fā)框架 ,它的核心是數(shù)據(jù)驅(qū)動UI的思想,讓我們從繁瑣的crud開發(fā)中解脫出來,本文將給大家介紹一下使用SpringBoot+Avue實現(xiàn)短信通知功能,文中有詳細的代碼示例,需要的朋友可以參考下2023-09-09

