网上有许多文章介绍如何解决此问题,一般都是说配置tool.jar的依赖。在M2E的官网的FAQ里找到了解决方法,链接地址:http://wiki.eclipse.org/M2E_FAQ#Unable_to_locate_the_Javac_Compiler_Error
第一种方法就是在eclipse的配置文件中指定javaw.exe的路径,仅需要配置
-vm
C:\jdk1.6.0\bin\javaw.exe
如果用文中提到的第二种方法,plugin配置中的两个Id都应该是大写首字母的,具体如下:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>eclipse</compilerId>
</configuration>
<dependencies>
<dependency>
<groupid>org.codehaus.plexus</groupid>
<artifactid>plexus-compiler-eclipse</artifactid>
<version>xxxx</version>
</dependency>
</dependencies>
</plugin>
另外就是,如果仅用第二种方法,在Eclipse的Markers里还是会提示错误,但是执行maven编译时不会报错。