0

I am trying to update a dependency in IntelliJ. Unfortunately, IntelliJ always loads the dependency with the old version.

At the beginning I was wondering because the application runs fine when I start it with Maven. But when I want to start it with IntelliJ I get the following error:

IntelliJ Idea mapstruct java: Internal error in the mapping processor: java.lang.NullPointerException


After all solutions I have tried, Maven always shows the old version 1.3.1.Final in the Dependency:Tree. What I have tried:

1) I quickly found a similar question (IntelliJ Idea mapstruct java: Internal error in the mapping processor: java.lang.NullPointerException)

  • Upgrade the maven version to 1.4.1.Final
  • Delete manually mapstruct 1.3.1.Final from External Libraries(Project Structure | Libraries)
  • mvn clean package
  • Click reload all maven projects

2) Trying to have IntelliJ automatically reload the change:

  • Settings -> Build, Execution, Deployment -> Build Tools -> Reload project after changes in the build scripts: From "External Changes" to "Any Changes"
  • Then I changed the version in the pom file from 1.3.1.Final to 1.4.1.Final

3) Trying to have IntelliJ automatically reload the change, trial number 2:

  • Setting -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing -> Generated sources folders: "Detect automatically"
  • Then I changed the version in the pom file from 1.3.1.Final to 1.4.1.Final

4) Clear the cache in IntelliJ:

  • File -> Invalidate Caches/Restart...

The snippets of the pom file:

<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>

EDIT: You can see the full pom.xml file via this link.

EDIT2: Probably the version is pulled from the Jhipster dependencies.

Pom snippet:

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

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

Why the explicit version in the properties does not overwrite the version of the parent pom (JHipster dependencies)

Kleinstein11
  • 95
  • 2
  • 9

1 Answers1

1

Your POM does not have an explicit version.

The property <mapstruct.version>1.4.2.Final</mapstruct.version> is only useful if it is used somewhere (it does not automatically change a version).

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • But why is it not explicit? I thought it would be Option 2 from this site https://spring.io/blog/2016/04/13/overriding-dependency-versions-with-spring-boot. – Kleinstein11 Mar 25 '21 at 18:17
  • It is only explicit, if at some place, there is `${mapstruct.version}`, e.g. in the parent POM. – J Fabian Meier Mar 25 '21 at 19:04
  • ok but there is a place...in . But I think the parents POM overrides this, isn't it? – Kleinstein11 Mar 25 '21 at 20:51
  • You are injecting the dependencies defined by jHIpster through a POM import. Using a property does not override the version from the parent POM. In addition to that parent POM cannot control what is in `annotationProcessorPaths` – Filip Mar 29 '21 at 06:46