Solve the error when maven project is packaged: Error injecting constructor

created at 08-27-2021 views: 603


When the maven project was packaged, an error was reported: 

Error injecting constructor, java.lang.ExceptionInInitializerError: Cannot access defaults field of Properties at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source) while locating org.apache.maven. plugin.war.WarMojo

When locating org.apache.maven.plugin.war.WarMojo, the default fields of the properties at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source) cannot be accessed.


I found a lot of methods on the Internet, and finally came to the conclusion:

It has nothing to do with the code, just specify the version of the package plugin in pom.xml:



My jdk version is 16, changed to the current latest package plugin version 3.2.2 to successfully package.

created at:08-27-2021
edited at: 06-04-2022: