弹簧靴1.5.14的球衣不起作用

时间:2018-06-24 12:07:34

标签: rest spring-boot jersey

我正在尝试使用spring-boot 1.5.14创建球衣jax-rs rest项目。 我已经在依赖中使用了春季球衣启动器。但不起作用。 请查看我的pom below。

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.14.BUILD-SNAPSHOT</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
<dependences>
 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
</dependences>

它不起作用。 @Path @Get那些所有的jax-rs注释都没有解决。 我已添加

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.1</version>
</dependency>

然后解决。另一个问题来了。

register(RequestContextFilter.class);没有解决。 然后我添加了---

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-common</artifactId>
    <version>2.24.1</version>
</dependency>

现在已解决,但在运行时出现新错误。 找不到org / jvnet / hk2 / spring / bridge / api / SpringBridge类def。 再次我添加了---

<dependency>
    <groupId>org.glassfish.hk2</groupId>
    <artifactId>spring-bridge</artifactId>
    <version>2.2.0-b14</version>
</dependency>

现在出现了另一个错误- 找不到org / glassfish / hk2 / api / ServiceLocatorFactory $ CreatePolicy类def。 我又添加了。

 <dependency>
        <groupId>org.glassfish.hk2</groupId>
        <artifactId>hk2-api</artifactId>
        <version>2.1.9</version>
    </dependency>

现在它正在给予---- 找不到org / glassfish / hk2 / utilities / binding / AbstractBinder类def

我添加了h2k api 再次给 java.lang.NoClassDefFoundError:org / glassfish / hk2 / api / ServiceLocator。 我升级了hk2 api版本。然后找不到类jersey.repackaged.com.google.common.base.Function 我添加了

<dependency>
    <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
    <artifactId>jersey-guava</artifactId>
    <version>2.25.1</version>

最后,它给出了-“未提供生成器,并且没有默认的生成器已注册-IllegalArgs异常。

如果我胆怯。那么就不会为休眠验证器抛出任何实现

1 个答案:

答案 0 :(得分:1)

可能是因为您将BUILD-SNAPSHOT用于Spring Boot的父版本。如果要使用快照版本,则需要在pom中配置快照存储库。这就是为什么无法解决Jersey起动器依赖性的原因。您要使用的是RELEASE版本。所有Spring发行版均以该后缀结尾。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.14.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>