我正在使用改编的pom.xml建立一个新的maven java项目.编译器在生成的maven java应用程序上给出错误.为什么这样?
我使用java 1.8和java 11修改了pom.xml以进行编译,两者都不起作用.Pom.xml适用于fatjar的生成,当每个java代码被删除时,它会起作用.Pom.xml适用于junit 4.11.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.no-ip.leder.gmr</groupId>
<artifactId>gmr_mvn</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>gmr_mvn</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>11</jdk.version>
<jodatime.version>2.5</jodatime.version>
<junit.version>4.11</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>gmr-digital-signature-mvn</finalName>
<plugins>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>org.no-ip.leder.gmr.Start</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
预期:来自maven框架的App.java中的Hello world编译或任何其他java源代码.实际:error: ';' expected
package org.no-ip.leder.test;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
Run Code Online (Sandbox Code Playgroud)
即使是未经修改的pom.xml,包含源和目标1.6,也会出现错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test_mvn: Compilation failure
[ERROR] /home/leder/Git/test_mvn/src/main/java/org/no-ip/leder/test/App.java:[1,15] ';' expected
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.no-ip.leder.test</groupId>
<artifactId>test_mvn</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>test_mvn</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
363 次 |
| 最近记录: |