Jersey:找不到类型为public javax.ws.rs.core.Response的参数的注入源

时间:2016-08-09 18:51:57

标签: jersey jersey-2.0 jersey-1.0

以下是我的web.xml

<web-app>
    <display-name>Kafka_APIs_LogManagement</display-name>
    <servlet>
        <servlet-name>myapplication</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.apis</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.scanning.recursive</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.classnames</param-name>
            <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>myapplication</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <error-page>
        <error-code>404</error-code>
        <location>/Error_404.jsp</location>
    </error-page>

    <error-page>
        <error-code>500</error-code>
        <location>/Error_500.jsp</location>
    </error-page>

    <welcome-file-list>  
        <welcome-file>Error_404.jsp</welcome-file>  
        <welcome-file>Error_500.jsp</welcome-file>  
    </welcome-file-list>  

</web-app>

以下是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.apis</groupId>
    <artifactId>my_APIs</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>my_APIs</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.10.68</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.2</version>
            <type>jar</type>
        </dependency> 


        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>6.0.2</version>
        </dependency>

<!--JERSEY DEPENDENCIES -- >

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.23.2</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.23.2</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-multipart</artifactId>
        <version>2.23.2</version>
    </dependency>

  <!--JERSEY DEPENDENCIES -- >  

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
            <type>jar</type>
        </dependency>




        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.4.2</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>myAPIS</finalName>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

以下是我的方法签名:

@POST
    @Path("/upload/{filename}/{type}")
    @Produces("application/json")
    @Consumes(MediaType.MULTIPART_FORM_DATA)

    public Response kafkaBulkProducer(InputStream a_fileInputStream,
                                      @PathParam("filename") String filename,
                                      @PathParam("type") String type,
                                      @Context ContainerRequestContext crc,
                                      @FormDataParam("file") InputStream fileInputStream,
                                      @FormDataParam("file") FormDataContentDisposition contentDispositionHeader)  {
}

我面临以下错误:

[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response

如果我删除了@FormDataParam,它会完美编译并按预期运行,但如果我将这两行引入我的代码,我会收到错误。

我已经通过以下链接,但我无法解决我的问题。 Link

谢谢

0 个答案:

没有答案