Ich habe 3 Methoden in ProfileResource
:Planung REST Ressource mehrere Methoden zu unterstützen, die produziert und verbraucht genau die gleichen Mime-Typen
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Profile> getAllProfiles() {
return profileService.getAllProfiles();
}
@GET
@Path("{profileId}")
@Produces(MediaType.APPLICATION_JSON)
public Profile getProfile(@PathParam("profileId") String profileId) {
return profileService.getProfile(profileId);
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public Profile getProfileByName(@QueryParam("profileName") String profileName) {
return profileService.getProfileByName(profileName);
}
Während Serverstart unter Fehler ausgelöst wird, da beide getAllProfiles
und getProfileByName
Methoden GET
sind Methoden, beide produzieren MediaType.APPLICATION_JSON
und es gibt keine Path
Differenz b/n sie.
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public restapi.model.Profile restapi.resources.ProfileResource.getProfileByName(java.lang.String) and public java.util.List restapi.resources.ProfileResource.getAllProfiles() at matching regular expression /profiles. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='[email protected]']
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:555) ~[jersey-server-2.22.2.jar:na]
Wie wird das Problem gelöst?
Können wir dieses Problem nicht lösen, ohne einen neuen Pfad anzugeben? –
das ist, was ich in der Antwort sagte – SivaTeja
@ Tom Howard Irgendwelche Eingaben? –