【问题标题】:The Gson.jar do not refer to Maven Dependency, even through it has being managed by spring-bootGson.jar 不引用 Maven 依赖项,即使它已由 spring-boot 管理
【发布时间】:2017-05-08 06:54:25
【问题描述】:

首先,在 Spring-boot 中构建项目。然后我想使用gson,所以我在pom.xml中添加了依赖。但出现警告:

The managed version is 2.8.0 The artifact is managed in org.springframework.boot:spring-boot-dependencies:1.5.3.RELEASE

我点击它,发现 spring-boot 确实已管理:click here 但是,如果我自己删除了依赖声明,gson.jar 就消失了。我不能使用gson... 那么如何使用spring-boot依赖管理的gson呢?

【问题讨论】:

  • 显然,您正在使用某种 IDE,它试图为您解决问题。您始终可以在命令行上使用 mvn dependency:list 或 mvn dependency:tree 来查看包含的内容和原因。您使用的是哪个 IDE?
  • 我在mac上用eclipse,有关系吗?

标签: java maven spring-boot gson


【解决方案1】:

是的,spring boot 提供了 Gson 依赖,你可以直接使用它而无需明确定义。在没有依赖定义的情况下访问 gson 时,您不应该遇到任何问题。我自己试过并且能够使用它。尝试更新项目(即,如果您使用 Eclipse 右键单击​​项目 > Maven > 更新项目.. > 单击强制更新快照/发布)。

【讨论】:

  • 我试过了,但没用。我在 maven 依赖项中找不到 gson.jar...我在 mac 上使用 eclipse
  • 你能分享你的 pom.xml 吗?
  • <groupId>muyi</groupId> <artifactId>weather</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
猜你喜欢
  • 2022-12-23
  • 2011-04-07
  • 2023-04-09
  • 2017-11-10
  • 2021-05-15
  • 1970-01-01
  • 1970-01-01
  • 2011-12-25
  • 2019-03-31
相关资源
最近更新 更多