java-8 – 在java 8中构建maven程序集
发布时间:2020-12-15 04:27:28 所属栏目:Java 来源:网络整理
导读:我在我的Project中更改了使用的 java版本.现在我正在使用lambdas表达式. 如果我编译IDE(IntelliJ),它运行良好.但是当我使用maven:assembly进行编译时,它会失败. 这是输出: [ERROR] ...../commands/parser/CommandParser.java:[141,73] lambda expressions
我在我的Project中更改了使用的
java版本.现在我正在使用lambdas表达式.
如果我编译IDE(IntelliJ),它运行良好.但是当我使用maven:assembly进行编译时,它会失败. 这是输出: [ERROR] ...../commands/parser/CommandParser.java:[141,73] lambda expressions are not supported in -source 1.5 [ERROR] (use -source 8 or higher to enable lambda expressions) 和我的pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.lefrantguillaume</groupId> <artifactId>ServerTinyTank</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>com.esotericsoftware</groupId> <artifactId>kryonet</artifactId> <version>2.22.0-RC1</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>args4j</groupId> <artifactId>args4j</artifactId> <version>2.32</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <source>${java.version}</source> <target>${java.version}</target> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.lefrantguillaume.Main</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> 解决方法
据我所见,你永远不会设置${java.version}.而且,您不在编译器目标中设置该变量.
它应该是什么样子: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.lefrantguillaume</groupId> <artifactId>ServerTinyTank</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <url>http://maven.apache.org</url> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>com.esotericsoftware</groupId> <artifactId>kryonet</artifactId> <version>2.22.0-RC1</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>args4j</groupId> <artifactId>args4j</artifactId> <version>2.32</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <source>${java.version}</source> <target>${java.version}</target> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.lefrantguillaume.Main</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |