将Jersey 1更新为Jersey 2 - Guice配置 - GuiceContainer和PackagesResourceConfig无法解析为类型

时间:2016-05-16 11:39:08

标签: rest servlets jersey guice jersey-2.0

我有项目Guice - Jersey 1.19项目的依赖项:

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey.contribs</groupId>
        <artifactId>jersey-multipart</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey.contribs</groupId>
        <artifactId>jersey-guice</artifactId>
        <version>${version.jersey}</version>
    </dependency>

我用泽西岛版本2.22.2替换了它们:

    <dependency>
        <groupId>com.squarespace.jersey2-guice</groupId>
        <artifactId>jersey2-guice</artifactId>
        <version>0.10</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>${version.jersey}</version>
    </dependency>
    <dependency>
        <groupId>com.owlike</groupId>
        <artifactId>genson</artifactId>
        <version>1.4</version>
    </dependency>

我上课了(&#34; / rest / *&#34;)。(GuiceContainer.class,params);但目前没有PackagesResourceConfig和GuiceContainer。

public class BootstrapServletModule extends ServletModule {

     private static final String propertyPackages = GenericBootstrapConstants.JERSEY_PROPERTY_PACKAGES;

    @Override
    protected void configureServlets() {
        super.configureServlets();

        ...

        Map<String, String> params = new HashMap<String, String>();
        params.put(PackagesResourceConfig.PROPERTY_PACKAGES, propertyPackages);
        serve("/rest/*").with(GuiceContainer.class, params);    
    }
}

如何在泽西岛2中使用params /替换GuiceContainer?

0 个答案:

没有答案