1、 Question
This is the first time I learned Maven from the teacher of station B. because the video is previous, now I learn the knowledge of the past. First of all, we use the latest software or various packages, which leads to a version problem. This problem is really a headache.
The problem I encountered this time is: open the CMD command window to execute“` MVN compile ` ` ` command, prompt “[error] no longer supports source option 5. Please use version 7 or later.” error message.
2、 Cause
This is the version mismatch I just talked about. It is mainly the problem of configuration in pom.xml file
The teacher is configured as:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apche.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.njpowernode</groupId> <artifactId>ch01-maven</artifactId> <version>1.0-SNAPSHOT</version> </project>
3、 Solution
Add the following code to the teacher’s configuration:
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.encoding>UTF-8</maven.compiler.encoding> <java.version>1.8</java.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>
4、 Final result
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apche.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.encoding>UTF-8</maven.compiler.encoding> <java.version>1.8</java.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <groupId>com.njpowernode</groupId> <artifactId>ch01-maven</artifactId> <version>1.0-SNAPSHOT</version> </project>
5、 Successful execution