Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of maven.compiler.source and maven.compiler.target in maven

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how to solve the problem of maven.compiler.source and maven.compiler.target in maven". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to solve the problem of maven.compiler.source and maven.compiler.target in maven".

The pit of maven maven.compiler.source and maven.compiler.target

Recently, the product group was advised to upgrade jdk 1.7 to 1.8. Last night, the developer reported a problem, saying that after maven.compiler.source and maven.compiler.target were changed to 1.8, the compiled code was still 1.7, as follows:

You can also view the java compiled version number of the class file through javap-v ServiceImpl.class.

In the afternoon, I took the time to take a look, and sure enough, the first suspicion was that the two parameters maven.compiler.source and maven.compiler.target were unreliable.

Take a look at the JDK configured by IDE

As follows:

After automatic build, it is indeed jdk 1.7

As follows:

Replace it with J2SE-1.8

Change it to 1.6

Looking up the official maven documentation, you can see that maven.compiler.source and maven.compiler.target are only recommendations, not mandatory.

If you want to force the jdk version

You can specify the executable attribute to guarantee it, as follows:

[...] [...] Org.apache.maven.plugins maven-compiler-plugin 3.7.0 true true 1.3 [...] [...]

Problem solved.

Maven compiler error java:-source,pom setting maven.compiler.source principle

The plug-in Maven compiler Plugin we compiled is used to compile code. When we were just learning java, we used the javac command to compile .java files into .class files.

And set up

${java.version} ${java.version}

Is to specify javac-source and target options, the official website

Sometimes, the diamond operator is not supported in maven compilation error java:-source 1.5 because no compiled version is specified. Just specify the version.

The above is all the content of this article entitled "how to solve the problem of maven.compiler.source and maven.compiler.target in maven". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report