Kaushik
Kaushik

Reputation: 177

Getting 404 - No message found after migrating to Spring Boot 2.x

After I made all the necessary changes to migrate from Spring Boot 1.5.4 to 2.1.1, I'm getting a 404 not found error. I think it is something with the controller's url mapping. I've made sure my main class and controllers are in correct place as I've placed my controller package after the main class. I've also used @ComponentScan and @SpringBootApplication annotations.

@RestController
@RequestMapping("/feature")
public class FeatureController {
        @RequestMapping(value = "user", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
        public String getFeatureForuser(@PathVariable("user_id") String userEId) {
            LOGGER.info("Fetching the avaliable features for User: {}", userEId);
            // Invoke the service layer.
            return service.getFeatureForuser(userEId);
        }
    }

Upvotes: 0

Views: 1119

Answers (2)

Kaushik
Kaushik

Reputation: 177

I was able to fix it after I changed server.contextPath to server.servlet.context-path in application.properties file because from Spring Boot 2.x a number of servlet specific properties have changed from server.* to server.servlet.*.

I hope this will be helpful. Thanks you all for helping!

Upvotes: 3

SpringMe
SpringMe

Reputation: 39

did you try @SpringBootApplication(scanBasePackages = " give your base package")

also the @RequestMapping(value = "user" should be @RequestMapping(value = "/user"

Upvotes: -1

Related Questions