2
我有一個資源,這是一個安全的,如果我刪除身份驗證,它似乎工作,但沒有安全,那麼有什麼意義?將參數傳遞給一個安全的dropwizard資源
這裏是我的代碼:
@POST
@Path("/secured")
@Timed
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@UnitOfWork
@RolesAllowed("mainUser")
public Response aliveSecure(@Auth User user, CustomRequest test)
{
CustomResponse resp = new CustomResponse();
System.out.println(test.getMessage());
return Response.status(Response.Status.ACCEPTED).entity(resp).build();
}
的CustomRequest和CustomResponse類型是非常標準的POJO,他們剛剛舉行了一個名爲「消息」的字符串 - 他們實際上是相同的,但是這僅僅是一個鍛鍊,我想爲了學習DropWizard而完成。
現在,如果我刪除@Auth這裏的東西,和@RolesAllowed等 - 使它不安全,然後該方法執行正常 - 但是,這是我嘗試啓動應用程序時得到的錯誤。
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
! [[FATAL] No injection source found for a parameter of type public CustomRequest at index 0.;
立即修好了!!!!謝謝!! :) – MickeyThreeSheds
@MickeyThreeSheds很高興知道。 :) – nullpointer