我在使用自定义 RestResource 时遇到问题。我想用我自己的实现替换 OOTB UserRestResource。当核启动时,我得到以下异常:
Scan failed to process nucleus rest resource class:class com.test.restresources.UserRestResource
path:/atg/userprofiling/restresources/UserRestResource
atg.service.jaxrs.RestException: Endpoint annotated method without a http method annotation
该类具有以下实现:
@RestResource(id = "com.pki.ebusiness.ocs.restresources.userRestResource")
@Path("/users")
@Api(value="/users")
public class UserRestResource extends GenericService {
private UserRepository mUserRepository;
private DomainObjectMapper mObjectMapper = DomainObjectMapper.INSTANCE;
@GET
@Path("/{userId}")
@Endpoint(id = "/users/{userId}#GET", isSingular = true, filterId = "users.id-Default")
@ApiOperation("Retrieve a user for given ID.")
public RepresentationModel getUser(@PathParam("userId") String pUserId){
User user = null;
try {
user = mUserRepository.getUser(pUserId);
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
UserDto userDto = mObjectMapper.convert(user);
Builder builder = (new Builder()).state(userDto);
return builder.build();
}
}
在调试 RestResourceRegistry 时,我发现它无法找到 Path 注释,即使它在那里。