有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java SpringBoot无法添加Google Guava依赖项

我想将番石榴系列添加到我的应用程序中,但未能成功。以下是我对pom的定义:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        <version>2.1.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
    </dependency>

我想使用MultiMap,但它看不到Guava依赖项。另一方面,我的IDE建议我在Glassfish中org.jvnet.hk2.component。但是我不使用玻璃鱼

如何添加番石榴依赖项并删除Glassfish依赖项


共 (2) 个答案

  1. # 1 楼答案

    您还需要添加spring上下文支持

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
    </dependency>
    
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>19.0</version>
    </dependency>
    
  2. # 2 楼答案

    看起来像是版本兼容性问题

    Guava默认值随spring boot server提供,如果需要特定版本,则必须使用特定版本覆盖默认值