簡體   English   中英

在 localhost 中打開 eureka 頁面時出現 404 錯誤

[英]404 error while opening eureka page in localhost

我已經使用 gradle 從 intellij 啟動了我的Eureka Server ,並且服務器已按照日志啟動並運行。 但是通過使用以下 url 在瀏覽器中出現404錯誤

http://localhost:8761/eureka/

請從 intellij 控制台找到日志

2020-07-12 13:57:27.988  INFO 24624 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initializing ...
2020-07-12 13:57:27.990  INFO 24624 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Adding new peer nodes [http://localhost:8761/eureka/]
2020-07-12 13:57:28.370  INFO 24624 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2020-07-12 13:57:28.370  INFO 24624 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2020-07-12 13:57:28.370  INFO 24624 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2020-07-12 13:57:28.370  INFO 24624 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2020-07-12 13:57:28.507  INFO 24624 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:  http://localhost:8761/eureka/
2020-07-12 13:57:28.516  INFO 24624 --- [           main] c.n.e.registry.AbstractInstanceRegistry  : Finished initializing remote region registries. All known remote regions: []
2020-07-12 13:57:28.518  INFO 24624 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initialized
2020-07-12 13:57:28.531  INFO 24624 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2020-07-12 13:57:28.620  INFO 24624 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application UNKNOWN with eureka with status UP
2020-07-12 13:57:28.622  INFO 24624 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..
2020-07-12 13:57:28.622  INFO 24624 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default
2020-07-12 13:57:28.622  INFO 24624 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test
2020-07-12 13:57:28.640  INFO 24624 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false
2020-07-12 13:57:28.641  INFO 24624 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context
2020-07-12 13:57:28.641  INFO 24624 --- [      Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node
2020-07-12 13:57:28.641  INFO 24624 --- [      Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 1
2020-07-12 13:57:28.641  INFO 24624 --- [      Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP
2020-07-12 13:57:28.649  INFO 24624 --- [      Thread-11] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2020-07-12 13:57:28.661  INFO 24624 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8761 (http) with context path ''
2020-07-12 13:57:28.662  INFO 24624 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2020-07-12 13:57:28.892  INFO 24624 --- [           main] c.l.m.e.EurekaServiceApplication         : Started EurekaServiceApplication in 6.138 seconds (JVM running for 6.688)
2020-07-12 13:57:33.891  INFO 24624 --- [nio-8761-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-07-12 13:57:33.891  INFO 24624 --- [nio-8761-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-07-12 13:57:33.900  INFO 24624 --- [nio-8761-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms
2020-07-12 13:58:28.642  INFO 24624 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
2020-07-12 13:59:28.642  INFO 24624 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms

application.properties 文件。

server.port=8761

#telling the server not to register himself in the service
eureka.client.register-with-eureka=false

#Eureka clients fetch the service registry (ServiceInstance : (URL, PORT, HOST)) from the Eureka server
eureka.client.fetch-registry=false

我的設置就是這樣並且工作正常:

應用.java

@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }

}

應用程序.yml

server:
  port: 8761

management:
  endpoints:
    web:
      exposure:
        include: '*'

eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false

pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ru.eureka</groupId>
<artifactId>eureka-server</artifactId>
<version>0.0.1</version>
<name>eureka-server</name>
<description>Eurka server</description>

<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>Greenwich.RC2</spring-cloud.version>
</properties>

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </repository>
</repositories>

<dependencies>
    <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-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</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>
            <configuration>
                <layout>ZIP</layout>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

嘗試在主 class 中添加@EnableEurekaServer

嘗試點擊 url:

http://localhost:8761/

代替

http://localhost:8761/eureka/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM