Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
解决办法:
需要检查的几个地方:
1.Java Build Path 需要选择JDK1.8
2.Java Compiler 需要选择1.8
3.如果配置了maven-assembly-plugin,需要指定maven-compiler-plugin为1.8
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
<arg>-parameters</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
</plugin>
<!-- mvn打包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>make-zip</id>
<!-- 绑定到package生命周期阶段上 -->
<phase>package</phase>
<goals>
<!-- 绑定到package生命周期阶段上 -->
<goal>single</goal>
</goals>
<configuration>
<descriptors> <!--描述文件路径 -->
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
在项目src下新建文件夹assembly,放assembly.xml。
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<formats>
<!-- 可以配置多个包的格式 -->
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/conf</outputDirectory>
<includes>
<include>*.xml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/</directory>
<outputDirectory>/bin</outputDirectory>
<includes>
<include>*.properties</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/java</directory>
<outputDirectory>/java</outputDirectory>
<includes>
<include>*.java</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<!-- 将scope为runtime的依赖包打包到lib目录下。
<scope>runtime</scope> -->
</dependencySet>
</dependencySets>
</assembly>