如何更新 Intellij 中的 mapstruct 依赖项?

时间:2021-03-25 12:11:55

标签: maven intellij-idea pom.xml jhipster mapstruct

我正在尝试更新 IntelliJ 中的依赖项。不幸的是,IntelliJ 总是使用旧版本加载依赖项。

一开始我想知道是因为当我用 Maven 启动它时应用程序运行良好。 但是当我想用 IntelliJ 启动它时,我收到以下错误:

<块引用>

IntelliJ Idea mapstruct java:映射处理器中的内部错误: java.lang.NullPointerException


在我尝试过所有解决方案之后,Maven 总是在 Dependency:Tree 中显示旧版本 1.3.1.Final。我尝试过的:

1)我很快发现了一个类似的问题 (IntelliJ Idea mapstruct java: Internal error in the mapping processor: java.lang.NullPointerException)

  • 将 Maven 版本升级到 1.4.1.Final
  • 从外部库中手动删除 mapstruct 1.3.1.Final(项目结构 | 库)
  • mvn 清洁包
  • 点击重新加载所有 Maven 项目

2) 尝试让 IntelliJ 自动重新加载更改:

  • 设置 -> 构建、执行、部署 -> 构建工具 -> 在构建脚本更改后重新加载项目:从“外部更改”到“任何更改”
  • 然后我将 pom 文件中的版本从 1.3.1.Final 更改为 1.4.1.Final

3) 尝试让 IntelliJ 自动重新加载更改,试用编号 2:

  • 设置 -> 构建、执行、部署 -> 构建工具 -> Maven -> 导入 -> 生成的源文件夹:“自动检测”
  • 然后我将 pom 文件中的版本从 1.3.1.Final 更改为 1.4.1.Final

4) 清除 IntelliJ 中的缓存:

  • 文件 -> 使缓存无效/重新启动...

pom 文件的片段:

<properties>
      <mapstruct.version>1.4.2.Final</mapstruct.version>
</properties>

...

<dependency>
    <groupId>org.mapstruct</groupId>
    <artifactId>mapstruct</artifactId>
</dependency>
<dependency>
    <groupId>org.mapstruct</groupId>
    <artifactId>mapstruct-processor</artifactId>
    <scope>provided</scope>
</dependency>

...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        <annotationProcessorPaths>
            <path>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${mapstruct.version}</version>
            </path>
            <!-- jhipster-needle-maven-add-annotation-processor -->
        </annotationProcessorPaths>
    </configuration>
</plugin>

编辑:您可以通过 this link.

查看完整的 pom.xml 文件

EDIT2:可能是从 Jhipster 依赖项中提取的版本。

Pom 片段:

<!-- Dependency versions -->
<jhipster-dependencies.version>3.9.1</jhipster-dependencies.version>

谢赫:https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/3.9.1

为什么属性中的显式版本不会覆盖父 pom 的版本(JHipster 依赖)

1 个答案:

答案 0 :(得分:1)

您的 POM 没有明确的版本。

属性 <mapstruct.version>1.4.2.Final</mapstruct.version> 只有在某处使用时才有用(它不会自动更改版本)。