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
Similar Posts:
- [Solved] maven 3.5.0 combined with eclipse suggests solutions to lambda expressions are allowed only at source level 1.8 or above errors
- Unregistering JMX-exposed beans on shutdown Solution
- Maven no main manifest attribute when generate jar for project
- Springboot always reports an error when importing JSP dependencies
- Eureka server project startup error handling
- [Solved] Error attempting to get column ‘create_time‘ from result set. Cause: java.sql.SQLFeatureNotSupported
- Maven warnning: ‘build.plugins.plugin.version’ is missing [How to Solve]
- [Solved] Dynamic Web Module 3.0 requires Java 1.6 or newer
- Dynamic Web Module 3.1 requires Java 1.7 or newer
- maven web web.xmlThe markup in the document following the root element must be well-formed.