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)