Ошибка при попадании API в Spring.
Я создаю пример "Джерси + весна" из https://www.mkyong.com/webservices/jax-rs/json-example-with-jersey-jackson/
и я получаю ошибку сопоставления запроса в консоли.
Вот мой код
@Controller
@RequestMapping("/")
@ComponentScan("com.bonrix")
@Path("/json/metallica")
public class JersetController {
@GET
@Path("/get")
@Produces(MediaType.APPLICATION_JSON)
public Track getTrackInJSON() {
Track track = new Track();
track.setTitle("Enter Sandman");
track.setSinger("Metallica");
return track;
}
@POST
@Path("/post")
@Consumes(MediaType.APPLICATION_JSON)
public Response createTrackInJSON(Track track) {
String result = "Track saved : " + track;
return Response.status(201).entity(result).build();
}
}
Код конфигурации
public class AppInitializer implements WebApplicationInitializer {
public void onStartup(ServletContext container) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(AppConfig.class);
ctx.setServletContext(container);
ServletRegistration.Dynamic servlet = container.addServlet(
"dispatcher", new DispatcherServlet(ctx));
servlet.setLoadOnStartup(1);
servlet.addMapping("/");
}
}
Ошибка ::
May 01, 2018 12:39:50 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVCSampleApp//json/metallica/get] in DispatcherServlet with name 'dispatcher'
May 01, 2018 12:40:14 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVCSampleApp//json/metallica/get] in DispatcherServlet with name 'dispatcher'
May 01, 2018 12:40:24 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVCSampleApp/json/metallica/get] in DispatcherServlet with name 'dispatcher'
May 01, 2018 12:40:34 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVCSampleApp/get] in DispatcherServlet with name 'dispatcher