简体   繁体   中英

404 error while opening eureka page in localhost

I have started my Eureka Server from intellij using gradle and the server is up and running as per the logs. But am getting 404 error in browser by using the below url

http://localhost:8761/eureka/

Please find the log from intellij console

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 file.

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

my setup is like that and works fine:

Application.java

@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {

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

}

application.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>

Try adding @EnableEurekaServer in main class.

Try hitting url:

http://localhost:8761/

Instead of

http://localhost:8761/eureka/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM