Skip to content

Jax-rs annotation Path is not work in java spring boot?

I have spring boot application with starter version 2.1.16, and spring-boot-starter-web dependency. So, i want use library, and add dependency:


So when i create controller, and add @Path, @Get – i don’t get answer from the server (404 not found). How makes it work?

package com.example.test;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


public class MyController {

    //Doesn't work (404 not found
    public String check() {
        return "hi!";

    public String check2() {
        return "hi2!";


Add the following dependency in your pom.xml


if you use spring boot starter version 2.1.16, you will normally have a parent pom which will also define the default version for the above dependency.

Then replace @RestController with @Path("/") from package

Now it should be working.

Keep in mind your embedded server now, will be jersey instead of default tomcat.

Edit: Also as found from the author of the question another change is needed to register a ResourceConfig. This is also described here in the official documentation.