I have parent [project] pom which have the
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.4.0</version>
....
</plugin>
In subproject [childpom], I am getting this error on the first line
<?xml version="1.0" encoding="UTF-8"?>
Incompatible lifecycle mapping plugin version 1.4.0
jump to definition in parent pom.
Further env details:
IDE : Jboss jeveloper studio v9.0.0
JDK : java 8 64 bit.
MAVEN : apache-maven-3.3.3
I am new to maven, pls suggest me where I went wrong?
different eclipse depends different lots of locale jar files. so try use the relation version of the eclipse version.
you can find the version number from the installation folder. they should in features or plugins.
maybe is 1.6.2. you can try!
Related
I have downloaded Spring Tool Suite4 IDE, Java17 Came Along with that IDE. But i want to work on Java8.
I installed only java8 in my system and started working on to print just "Hello Spring Boot".
When i run the sample project the code is being compiled with java17 and trying to run with java8(which i have given in execution environments and build path)
I got error like below.
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/SpringApplication has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at com.aditya.springboot.HelloSpringBootProjectApplication.main(HelloSpringBootProjectApplication.java:10)
I changed the compiler compliance from 17 to 1.8 in windows-\>preferences-\>Compiler-\>JDK Compliance..,
I pointed the Installed JREs to from jre 17(default) to jdk 1.8 and
I changed the compiler compliance from 17 to 1.8 in project-\>properties-\>java compiler also.
I tried uninstalling the STS4 and reinstalling it, but still i am getting same error.
As i am using maven project i tried changing \<java.version\> to 1.8 from 17 in pom.xml file too.
Can anyone help me from where STS is taking java17 inorder to compile my code, i haven't installed java17 in my system also. I have pointed JAVA_HOME in enviroment variables(user level variable but not system level varaiable) to java8 only.
I think you might need to adjust your pom.xml if you are using it to configure the java version. However, you need to make sure that the spring boot version that you are using is compatible with java 8.
In your pom.xml add the following:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version> // your spring boot version
</parent>
............
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source> // the version you desire
<target>1.8</target> // the version you desire
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
for gradle:
plugins {
java
}
group = "com.group"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8 // desired version
java.targetCompatibility = JavaVersion.VERSION_1_8 // desired version
I found an answer
The problem is with java version in pom.xml file of Maven:
If i am creating a maven project with spring boot version 3+, pom.xml is taking java version as 17 by default. Even if we change the version to 1.8 in pom.xml it is showing error as version mismatch because pom.xml internally taking java17. When i changed the java version to 9 in pom.xml it compiled and ran successfully. so we need to use java9+ for spring boot 3+.
But still i want to use java 1.8 for project so i degraded springboot version:
For creating the same maven project i used spring boot version 2+(i.e 2.7.8).
Now maven by default took 1.8 version with out giving chance for us to modify.
My project ran with 1.8 successfully.
After adding module-info.java files to my project my checkstyle plugin start failing with:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check
(default-cli) on project email: Failed during checkstyle
configuration: NoViableAltException occurred during the analysis of
file
/home/xxx/IdeaProjects/blynk-server/server/notifications/email/src/main/java/module-info.java.
unexpected token: module -> [Help 1]
I tried
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
However, it failed with:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check
(default-cli) on project blynk: Failed during checkstyle
configuration: cannot initialize module
BeforeExecutionExclusionFileFilter - Unable to instantiate
'BeforeExecutionExclusionFileFilter' class, it is also not possible to
instantiate it as
com.puppycrawl.tools.checkstyle.checks.annotation.BeforeExecutionExclusionFileFilter
What is the correct way for skipping module-info.java files during checkstyle for maven-checkstyle-plugin?
Not sure why the Checkstyle filter is not working (this reported bug seems very similar to yours and it was fixed in version 7.3.0, so maybe you need to update Checkstyle).
Anyway the Maven excludes element is also supposed to do this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<excludes>**/module-info.java</excludes>
</configuration>
</plugin>
More in the plugin goal documentation.
BeforeExecutionExclusionFileFilter was added in Checkstyle 7.2.
But the maven-checkstyle-plugin version 3.0.0 (which is the latest version as of 2018-04-01) uses Checkstyle 6.18 by default.
"Checkstyle" and "Checkstyle Maven Plugin" are different things and have different release cycles.
You may want to upgrade the Checkstyle version as follows:
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version> <!-- Checkstyle Plugin version -->
<!-- ... Configuration, Executions ... -->
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.8</version> <!-- Checkstyle version -->
</dependency>
</dependencies>
</plugin>
After that, BeforeExecutionExclusionFileFilter as well as other newer Checkstyle features (e.g. new checks) will be recognized.
Though this doesn't possibly qualify as an answer. Yet being too long to fit in comment, just to keep a note of the track that the maven-checkstyle-plugin is in:-
The last release of the was version 2.17 on 15-Oct-2015 which was almost 2 years back.
The current trunk of maven-plugins points to an ongoing work within the plugin in its 3.0.0-SNAPSHOT version which might mean we can soon expect a org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0 sometime in near future and which would understand the module-info.java as a class.
This doesn't align with the Java+9+-+Jigsaw doc that specifies the list of modules and plugins that are being upgraded to support JDK-9.
I am using Tycho and Maven to build an eclipse update site containing several plugins. Everything worked happily when I packaged it as an eclipse-update-site, but I'm getting errors now that I've switched to eclipse-repository.
My projects looks like
com.mycompany.plugin/
src/things.java
pom.xml
com.mycompany.plugin.feature/
feature.xml
pom.xml
com.mycompany.updatesite/
category.xml (formerly site.xml)
pom.xml
This page indicates that the maven packaging "eclipse-update-site" is deprecated in favor of "eclipse-repository". Accordingly, I updated my update site's pom.xml to look like (approximately):
<project>
<tycho.version>0.26.0</tycho.version>
<groupId>mygroup</groupId>
<artifactId>artifactId</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
</plugins>
</build>
<packaging>eclipse-repository</packaging>
</project>
I also renamed my site.xml file to category.xml as suggested by this post and this post. I did not make any other changes to category.xml (formerly site.xml), so it looks like:
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/com.mycompany.plugin.feature_0.1.0.qualifier.jar" id="com.mycompany.plugin.feature" version="0.1.0.qualifier">
<category name="com.mycompany"/>
</feature>
<category-def name="com.mycompany" label="MyPlugin"/>
</site>
The maven build marches along happily, building all of my plugins and features. When it tries to build the repository, it fails, saying:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-repository-plugin:0.26.0:assemble-repository
(default-assemble-repository) on project com.mycompany.updatesite: Could not assemble p2 repository:
Mirroring failed: No repository found at file:/mypath/com.mycompany.updatesite/target/. -> [Help 1]
Clearly I'm missing something, but I can't figure out what.
Which phases of maven are you running?
I encountered the same problem when switching from eclipse-update-site to eclipse-repository and using just the package phase. However, it worked with install.
Or more specifically instead of
mvn clean package
I used
mvn clean install
I hope this helps you too.
I have Java version 1.8.111 installed and the initial error message after running mvn3 install was as below.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project myfile: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ vendor='sun' version='1.6' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.
To resolved this, I've updated my toolchains.xml to version 1.8.111 but still getting the same error. I've also tried after running mvn3 clean and successfully cleaned but still getting the same error.
Could anyone pinpoint where this version 1.6 is fetched from?
I checked JAVA_HOME already, it's set to 1.8.
Can anyone explain how maven calls Java version?
Appreciate your help.
Below is my toolchains.xml
Your application is expected to be built with JDK 1.6 and to locate it Maven is looking for definition of [ vendor='sun' version='1.6' ] within toolchains.xml in your {home}/.m2/ directory (see eg this maven guide). You just need to point to it and all should be good.
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/jdk1.6.X_XX.jdk/Contents/Home</jdkHome>
</configuration>
</toolchain>
</toolchains>
I have a project Maven ear modules, and i like to rename the ear from ProjectIt-4.1.0.ear to ProjectIt-4_1_0.ear in fact to have a version like that : x_y_z to resolve a deployement contraints
You can define a custom property holding your key with your own separtor between major, minor and maintenance version.
Then you can use that property in the build name of your artifact:
<project>
...
<properties>
<custom.version>x_y_z</custom.version>
</properties>
...
<build>
<finalName>${project.artifactId}-${custom.version}</finalName>
</build>
</project>
Meanwhile, I wouldn't advice such a method of shipping artifacts version, because it would not fit the common version syntax. You can read more about Semantic Versionin in semver.