I am currently trying to create a simple Spring Boot application that I can send a request from my Postman application to a rest endpoint and the application will perform a basic operation on the data handed over and return the result in a Response.
Here is my RestService class with one endpoint that returns a message to say it was connected to:
package TestRestService.TestRestService;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/testApplication")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public class RestServiceTest {
@GET
@Path("/hitme")
@Produces({ "application/json" })
public Response getServerInfo(){
String message = "Hit the end point";
return Response.ok(message).build();
}
}
Here is my main class:
@SpringBootApplication
public class App {
public static void main( String[] args ){
SpringApplication.run(App.class, args);
}
}
I have an index.html
containing a simple title and paragraph which shows when run the app on server.
I originally had a web.xml but that stopped me from connecting to any pages within the service so i deleted it and now I can access the index.html pages but no other points that I know of.
When I connect to http://localhost:8080/TestRestService/testApplication/hitme via Postman or in STS I get:
Can anybody advise of what I should be doing to be able to connect to these rest endpoints?