0

I am trying to create a simple app with jax rs, springboot, angular.

I have placed the index.html in static folder, but while hitting the url localhost:8080/index.html or localhost:8080 it's throwing 404 not found error through the custom exception handler. I have added index.html as welcome-file-list.

I have a controller class but i have not written any specific method to handle it.

Also i want to display error specific page with message details.

Definitely i am missing something but not getting any pointer to find it out. Please help.

Do i need to configure web.xml explicitly for this?

newcoder
  • 464
  • 9
  • 23
  • https://stackoverflow.com/a/29670751/2587435 – Paul Samsotha Jan 01 '19 at 17:13
  • @Paul Samsotha i am a novice so really dont have too much knowledge about these configurations, though i followed but didn't help. So i have removed the web.xml and springboot configure it. I can in log that it's detecting the index page but while hitting the url it is redirecting to my custom exception handler and throwing 404 error. As i saw some comments that springboot will automatically find these static pages and serve. I am not sure as i am using jax rs with springboot so may be i need to do something else. – newcoder Jan 03 '19 at 05:53
  • Do you have GitHub? If you do, can you post a link to the repo? I can look at it. – Paul Samsotha Jan 03 '19 at 05:57
  • Did you follow the directions in the link? And do you have the dependency in the [below answer](https://stackoverflow.com/a/53996036/2587435)? – Paul Samsotha Jan 03 '19 at 06:00
  • Yes all dependencies are there. I will see if i can upload it in github and will share the link. – newcoder Jan 03 '19 at 06:06

2 Answers2

0

Add

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

To your pom.xml file, spring boot auto configure all the rest.

Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114
0

I know this is older, but to expand on Itsik's answer I found this answer via this other answerto be very helpful in explaining this.

Summed up, if you want to be able to serve up resources/static/index.html AND use JAX-RS/jersey for api endpoints, include both spring-boot-start-web and spring-boot-starter-jersey. In your JerseyConfig add @ApplicationPath("/api") or whatever subpath you want all your jax-rs rest endpoints to live under. Then you will be able to have the best of both worlds.

TraumaER
  • 1
  • 3