没有为public java.util.List类型的参数找到注入源

时间:2016-04-20 11:13:30

标签: java spring spring-mvc swagger jersey-2.0

  

org.glassfish.jersey.server.model.ModelValidationException:应用程序初始化期间应用程序资源模型的验证失败。       [FATAL]找不到类型为public java.util.List

的参数的注入源
com.org.testing.controller.getSentInviteList(com.org.testing.domain.FriendshipInvitee$Status,com.org.testing.domain.ext.RequestBounds,javax.servlet.http.HttpServletResponse,org.springframework.security.core.Authentication) throws java.lang.IllegalAccessException,com.org.testing.exception.BusinessException at index 0.; source='ResourceMethod{httpMethod=POST, consumedTypes=[application/json], producedTypes=[application/json], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.org.testing.controller, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@190e93e3]}, definitionMethod=public java.util.List com.org.testing.controller.getSentInviteList(com.org.testing.domain.FriendshipInvitee$Status,com.org.testing.domain.ext.RequestBounds,javax.servlet.http.HttpServletResponse,org.springframework.security.core.Authentication) throws java.lang.IllegalAccessException,com.org.testing.exception.BusinessException, parameters=[Parameter [type=class com.org.testing.domain.FriendshipInvitee$Status, source=status, defaultValue=null], Parameter [type=class com.org.testing.domain.ext.RequestBounds, source=null, defaultValue=null], Parameter [type=interface javax.servlet.http.HttpServletResponse, source=null, defaultValue=null], Parameter [type=interface org.springframework.security.core.Authentication, source=null, defaultValue=null]], responseType=java.util.List<com.org.testing.domain.LeaderboardInvitation>}, nameBindings=[]}']

    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:467)
        at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:163)
        at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:323)
        at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
        at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:320)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
        at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
        at javax.servlet.GenericServlet.init(GenericServlet.java:244)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1274)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5033)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5320)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
        at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:125)
        at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:109)
        at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:122)
        at org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor.onStarted(StandardArtifactStateMonitor.java:271)
        at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:319)
        at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:316)
        at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:252)
        at org.eclipse.virgo.nano.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:140)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

我正在进行一个spring-mvc restfull webservice项目,我对Jersey和swagger来说都很新。我尽最大努力使用swagger为api创建文档。但在最后的时刻,我看到了一些带有招摇的球衣限制。

我已经涵盖了文档中的大多数api,但是有以下情况使用swagger创建文档问题。案例如下: -

  1. 如果Endpoint有多个输入参数(Request Params),Jersey只使用路径参数,它不支持Request params。
  2. 如果响应类型基于集合,则apis抛出异常。
  3. 如果Request params有任何集合类型输入参数。
  4. 我在我的项目中使用spring 3.x框架,我添加了jersey 2.12版本并使用了swagger 1.0。

    我正在寻求帮助来解决此错误。

    这是我的代码

    @Path("/invite/sent/list")
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(
            value = "get List", response=LBTest.class,
            responseContainer="List",
            notes = "API to get list.")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of resource options"), @ApiResponse(code = 500, message = "Internal server error"), @ApiResponse(code = 403, message = "Illegal Access of Resource") })
    @RequestMapping(value = "/v2/lb/invite/sent/list", method = RequestMethod.POST)
    @PreAuthorize("hasRole('ROLE_USER')")
    @ResponseBody
    public List<LBTest> getSentInviteList(@ApiParam(value = "status", required = false) @RequestParam(value = "status", required = false) Invitee.Status status, @RequestBody RequestBounds requestBounds,
            @Context HttpServletResponse response, @Context Authentication auth) throws IllegalAccessException, BusinessException
    {
    
       //Bussiness logic here
    }
    

0 个答案:

没有答案