Java spring编译错误:无法访问ParameteredTypeReference
我的任务是修改一个旧的Spring应用程序,我需要添加一些rest调用。当我尝试使用RestTemplate时,我遇到了一系列错误,并结束了从Spring2.x到4.x的升级。我现在得到:Java spring编译错误:无法访问ParameteredTypeReference,java,spring,maven,spring-mvc,Java,Spring,Maven,Spring Mvc,我的任务是修改一个旧的Spring应用程序,我需要添加一些rest调用。当我尝试使用RestTemplate时,我遇到了一系列错误,并结束了从Spring2.x到4.x的升级。我现在得到: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler- plugin:2.3.2:compile (default-compile) on project adddrop: Compilation failure [ERR
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:2.3.2:compile (default-compile) on project adddrop: Compilation failure
[ERROR] /Users/jim/Documents/Dev/academic-addDrop-
web/src/main/java/edu/addDrop/web/FormPageController.java:[744,4] error:
cannot access ParameterizedTypeReference
我运行了一个MVN依赖关系树,看到其他jar文件正在使用Spring3.1.1.RELEASE,所以我切换到了那个版本,但运气不好。在我的POM中,有弹簧芯:
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
更新:
如果切换到Spring 4.2.1.RELEASE,则会出现以下编译错误:
error: cannot access LabeledEnum
ParameterizedTypeReference
包含在spring core
中,从3.2开始,您应该使用更高版本的spring。使用spring 4
或spring 5
问题更新以包含代码。我之所以怀疑依赖性问题,是因为我所做的研究表明,依赖性存在冲突或缺失。这对我有帮助。查找依赖于依赖项(B)的库(A)。我找到了库(A)的pom.xml文件,它为我提供了一个关于依赖关系(B)的版本。我通常会发现我的pom.xml文件中有一个旧版本(或完全不同的新版本)的依赖项(B)。例如:谢谢Dave,实际上我最初尝试了4.2.1.RELEASE,但由于以下错误而放弃了:错误:无法访问LabeledEnum您可以尝试在spring中查找具有完整包名的LabeledEnum.class,如果您可以找到它,可能仍然存在依赖性问题。它似乎已被弃用为os spring 3.0:是,您在项目中引用过LabeledEnum吗?没有,它似乎与RestTemplate.exchange()有关。当我使用RestTemplate.getForObject时,这些问题都不会发生,但由于我需要包含标题,所以我需要使用exchange(),这就是我的进度到达终点的时候。
The type org.springframework.core.ParameterizedTypeReference cannot be resolved. It is indirectly referenced from required .class files
error: cannot access LabeledEnum