1

I create a eureka project in IDEA and it works well. But when I pack it into war and throw into webapp directory of tomcat 8.5. After restart tomcat,I can not access it by the url localhost:8761

EurekaApplication.java

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
    public static void main( String[] args ) {
        SpringApplication.run(EurekaApplication.class,args);
    }
}

application.yml

server:
  port: 8761

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serverUrl:
      defaultZone: http://localhost:${server.port}/eureka/

spring.cloud.config.discovery.enabled: true
LMC
  • 10,453
  • 2
  • 27
  • 52
fangwen
  • 11
  • 1

2 Answers2

1

Your EurekaApplication class should extends SpringBootServletInitializer and override configure method like bellow:

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

    return builder.sources(EurekaApplication.class);
}
0

Please check tomcat port number in server.xml and use that port number to load eureka server.

The eureka server access according to instance available in /webapp of your tomcat

For-example, I have folder discovery-service , the tomcat port is 8761: http://localhost:8761/discovery-service/

Zeb
  • 2,687
  • 7
  • 28
  • 36
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30546749) – MD. RAKIB HASAN Dec 15 '21 at 10:51