Я хочу, чтобы путь не был жестко закодирован, а был выбран из свойства, чтобы мы могли изменить его в соответствии с нашей потребностью.Как я могу указать значение пути из файла свойства в джерси?
Ниже код работает: ---
@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='org[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-адрес службы контролировался файлом свойств. Предположим, что для вызова getDesignations() URl будет http://192.168.1.46:9090/api/ws/v1/designations, тогда некоторое время в будущем я хочу, чтобы мой URL был http://192.168.1.46:9090/api/ws/ v1/desig для той же цели, то я должен изменить свой файл свойств, а не мой .java –