This is the 13th day of my participation in the August More Text Challenge.More challenges in August
directory
Solution 1: Modify the pom. XML file configuration
For solution 2, modify the configuration in Apache-Maven-3.2.2
Hello, I’m Grey Ape! A super bug writing program ape!
Continue to be a good bug fixer today!
The maven tool is used to test the builder. The project itself is not a problem. The folder, source code and so on have been built.
[ERROR] Failure executing javac, but could not parse the error
[ERROR] Source option 5 is no longer supported. Please use version 6 or higher.
[ERROR] The target option 1.5 is no longer supported. Please use version 1.6 or later.
The details are as follows:
An error occurred while executing the Java program, but the error type cannot be resolved. The error is no longer supported by source option 5. Please use version 6 or higher.” And “Error no longer supports target option 1.5. Please use version 1.6 or higher.” . Actually see this sentence, experienced old program ape people probably know what is wrong.
It’s just that some places are using things that are out of date and are no longer supported. So what exactly is out of date?
The main cause of this error is that the default JDK in the Maven configuration file is no longer used, so the program cannot run.
If you do not know the JDK version on your computer, you can enter “java-version” in CMD to view the JDK version. For example, mine is version 10.0.
Once you know your JDK version, there are two ways to solve this problem:
Solution 1: Modify the pom. XML file configuration
This approach requires modifying the contents of the pom.xml configuration file in which the project is currently running to add the following code. This tells the current project which version of the JDK to run with. For example, my JDK version is 10.0.1, so THE version is 10, but this method only works for the current project, for other projects that use the default JDK!
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<java.version>10</java.version>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
</properties>
Copy the code
For solution 2, modify the configuration in Apache-Maven-3.2.2
This method requires modifying apache-Maven-3.2.2 configuration on our computer as follows:
Setting. XML is stored in apache-maven-3.6.1\conf\settings. XML
2. Add JDK version description to setting. XML file.
3. Find the following tags in settings. XML and change the JDK version to the version on your current computer
<profile> < ID > JDK-10.0.1 </ ID > <activation> <activeByDefault>true</activeByDefault> < JDK >10</ JDK > </activation> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>10</maven.compiler.source> <maven.compiler.target>10</maven.compiler.target> </properties> </profile>Copy the code
Supplement:
Sometimes the following error is reported after the JDK version is changed according to the above steps:
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] Javac: Invalid target release: 10.0.1
Javac < options > < source file >
[ERROR] Use –help to list possible options
Your version number is incorrect. For example, if mine is 10.0.1, write 10 instead of 10.0.1 in the configuration file.
Then use maven to run the MVN conpile command and get the following message:
BUILD SUCCESS
The operation is successful. No problem!
If you have any new suggestions or solutions, please leave a comment!
I’m Grey Ape, and I’ll see you next time!