Plugins not found in sprinboot and maven - java

I have a new error in my project that is in the pom.xml file. How can I fix it?
The error below is
shown in IntelliJ idea:
Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found
Plugin 'org.apache.maven.plugins:maven-compiler-plugin:' not found
Plugin 'org.apache.maven.plugins:maven-compiler-plugin:' not found

Only add the version.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
<version>${project.parent.version}</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
Now its working.

Related

Type Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerial [duplicate]

When I am creating a Maven project I am getting this error in pom.xml
Could not initialize class
org.apache.maven.plugin.war.util.WebappStructureSerializer
-Maven Configuration Problem
web.xml is missing and <failOnMissingWebXml> is set to true.
It might because the version of maven-war-plugin is too old in your project.
Try to add below code in your pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
</build>
</project>
Note: you should have the build tag
place everything inside build tag then, it will not throw error
If you are getting this error within Eclipse (my Eclipse version was Version: 2021-09 (4.21.0), Build id: 20210910-1417 at the time of writing) and you recently tried to move to JDK 17, it appears Eclipse is not compatible with JDK 17. It requires at least JDK 11. I reverted back to Java 11.0.12 and the error has gone away.
I'm using Windows 10 and Eclipse Version: 2022-03 (4.23.0) Build id: 20220310-1457
My project uses JDK8, but newer versions of Eclipse require at least JDK11.
I configure this using Window->Preferences->Java->Installed JREs
as shown in the screenshot:
Maven from windows cmd shell works fine: mvn clean package
But, Eclipse gives an error on my pom.xml: Could not initialize class org.apache.maven.plugins.war.util.WebappStructureSerializer
For reference, Eclipse gave some other error messages while I was attempting to fix the issue, such as this one: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module
This error seems to be some compatibility issue with maven-war-plugin and the JDK17 that eclipse runs under. It's probably due to the 'module' permissions.
Using these helpful answers, I was able to find a workaround:
#Capricorn1 https://stackoverflow.com/a/69544567/4505142
#SreedharGS https://stackoverflow.com/a/29383652/4505142
I downloaded OpenJDK11 from: https://adoptium.net/
Updated eclipse.ini to use JDK11 instead of JDK17:
--launcher.appendVmargs
-vm
C:\Users\User1\OpenJDK11\jdk-11.0.15+10\bin
-vmargs
-Dosgi.requiredJavaVersion=11
-Dosgi.instance.area.default=#user.home/eclipse-workspace
-Dsun.java.command=Eclipse
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true
-Xms512m
-Xmx1024m
--add-modules=ALL-SYSTEM
For reference, here's the original eclipse.ini JDK17 path:
-vm
plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.2.v20220201-1208/jre/bin
Using JDK11 to run Eclipse, eliminated the pom.xml error "Could not initialize class org.apache.maven.plugins.war.util.WebappStructureSerializer"
For reference, here are the relevant snippets of my pom.xml:
<properties>
<spring-boot.version>1.5.13.RELEASE</spring-boot.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
</properties>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<packagingExcludes>**/application-*.properties</packagingExcludes>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>prepare-package</phase>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
In Pom.xml, need to add the below snippet, and please find image attachment
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
</build>
After update Maven Project
enter image description here
Please use the below code snip:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</pluginManagement>
Please refer this
Try to add the plugin to your maven project, by adding this in your pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
After that: Right click -> Maven -> Update Project
I have the same problem as this when I create a maven project. So I got a solution for this just adding this plug into your pom.xml:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
If you already have it, then you should upgrade its version.

Updating Maven Project does not move from 75

I have this problem. I have just started a new Maven project and, after adding this code:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-war-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
The project is freezed on "Updating Maven Project 75", I am trying to search a solution, but no one is working. The funniest thing is I am following a course on line about Spring and it is just the first attempt to use Maven.
Tried to restart Eclipse, to delete and create a new project...

after upgrading to java 12, in which syntax and for what to use for surefire plugin and maven

i upgraded my java version to 12.0.2 in my system, and i have few projects where i have used maven 3.6.2, and some i used maven + surefire plugin 3.0.0-M8.
since i know that maven is working with java 1.6 and i need to update the compiler version to work with these, also i need to update the surefire plugin to work with the java 12 version,
so i want to understand in what to use, and on what (Maven or surefire or both) and also if the syntax is the right one?
also if these is not the right way, so what is the right one?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable> ${JAVA_HOME}/bin/javac </executable>
</configuration>
</plugin>
also
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
and also
<properties>
<maven.compiler.release>12</maven.compiler.release>
</properties>
and also
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>12</release>
</configuration>
</plugin>
</plugins>
</build>

Maven build fails with os-maven-plugin

I added the os-maven-plugin to my pom like so:
<build>
<extensions>
<!-- native platform classifier -->
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
On my dev machine I can compile and run this project just fine, however when I try to run the build via Jenkins it fails immediately and shows this error in the logs:
[INFO] Internal error in the plugin manager getting plugin
'org.apache.maven.plugins:maven-clean-plugin': Plugin
'org.apache.maven.plugins:maven-clean-plugin:2.5' has an invalid descriptor:
1) Plugin's descriptor contains the wrong group ID: kr.motd.maven
2) Plugin's descriptor contains the wrong artifact ID: os-maven-plugin
3) Plugin's descriptor contains the wrong version: 1.5.0.Final
Clearly, it seems to be using the descriptors from the os-maven-plugin to get the clean-plugin and fails because the descriptors don't match up for that plugin.
Why is this and how should I be incorporating the os-maven-plugin into my project?

Error using checkstyle/google_checks.xml with maven-checkstyle-plugin

I am trying to use checkstyles google_checks.xml with maven-checkstyle-plugin. If I use the google_checks.xml with the latest checkstyle intelliJ plugin everything is correct but when I try configurating it via maven-checkstyle plugin I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (default-cli) on project XX_XX_XX: Failed during checkstyle configuration: cannot initialize module TreeWalker - Unable to instantiate AvoidEscapedUnicodeCharacters:
Unable to instantiate AvoidEscapedUnicodeCharactersCheck
My pom.xml looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
[...]
<checkstyle.file.path>develop/checkstyle/google_checks.xml</checkstyle.file.path>
</properties>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<configuration>
<configLocation>${checkstyle.file.path}</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>${checkstyle.file.path}</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
</plugins>
</reporting>
Do you guys have some suggestions about what could be wrong?
fixed this by updating the checkstyle-dependency manually to the latest stable version:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.latest.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>${checkstyle.file.path}</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
Maven checkstyle plugin uses checkstyle 5.7 (the first line of plugin description).
Checkstyle 5.7 does not have this check (see checks package on grepcode).
You need either to disable this check or to wait for official fix of MCHECKSTYLE-261.
I give a demo at
https://github.com/favoorr/Maven-Checkstyle-Multimodule-Use
Multi modules and use Google Chechstyle

Categories