나는 경로를 하드 코딩하지 말고 오히려 우리가 필요에 따라 변경할 수있는 속성에서 선택해야합니다. ---저지에서 속성 파일의 경로 값을 어떻게 지정합니까?
@Path("ws/{version}")
public class DesignationResource {
@PathParam("version") String version =
Constants.API_VERSION; //(read from property file in class Constants)
@PathParam("servicename_designationList") String servicename_designationList=
Constants.API_POST_CITYLIST_NAME ; //(read from property file in class Constants)
@Path("{servicename_designationList}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDesignations()
{
/**
...CODES...
*/
}
}
하지만 클래스가 노력하고 던지는되지 예외 다음
코드의 두 가지 방법이있는 경우 : 코드 아래
작동 ---를
@Path("ws/{version}")
public class DesignationResource {
@PathParam("version") String version =
Constants.API_VERSION; //(read from property file in class Constants)
@PathParam("servicename_designationList") String servicename_designationList=
Constants.API_POST_CITYLIST_NAME ; //(read from property file in class Constants)
@PathParam("servicename_designationListId") String servicename_designationListId=
Constants.API_POST_CITYLISTID_NAME ; //(read from property file in class Constants)
@Path("{servicename_designationList}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDesignations()
{
/**
...CODES...
*/
}
@Path("{servicename_designationListId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDesignationsId()
{
/**
...CODES...
*/
}
}
는 예외 기록 예 : -----
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 javax.ws.rs.core.Response DesignationResource.getDesignations() and public javax.ws.rs.core.Response DesignationResource.getDesignationsId() at matching regular expression /([^/]+?). 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]', [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 javax.ws.rs.core.Response source='[email protected]'] at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:465) ...
각 방법의 목적은 무엇이며 각 URL에 보낼 예제 URL을 제공 할 수 있습니까? –
서비스 URL이 속성 파일에 의해 제어되기를 원합니다. getDesignations() URl을 호출한다고 가정하면 http://192.168.1.46:9090/api/ws/v1/designations 다음에 나중에 내 URL이 http://192.168.1.46:9090/api/ws/이되기를 원합니다. 같은 목적을위한 v1/desig 그럼 내 .java가 아닌 내 속성 파일을 변경해야합니다 –