为Maven指定tools.jar ,解决Missing artifact com.sun:tools:jar:1.5.0错误

使用安装了m2eclipse插件的eclipse导入maven工程后,pom.xml开始位置报:Missing artifact com.sun:tools:jar:1.5.0错误,不算是个大问题,但是这个错误会block eclipse build maven工程,关于这个问题有两种解决方法:

 

方法一:

 

在eclipse安装目录下找到eclipse.ini文件,在-vmargs参数上面追加vm参数,以下是一个例子:

-vm
D:\Java\jdk1.6.0_37\bin\javaw.exe

关于eclipse.ini文件的说明和-vm参数的设置可参考:http://wiki.eclipse.org/Eclipse.ini

不过有时候修改完eclipse.ini重启eclipse不一定会立即生效,你可以选中工程,右键,Maven -> Disable Maven Nature, 然后重新在项目上右击Configure —> Convert to Maven Project.

 

方法二:

 

扫描二维码关注公众号,回复: 725245 查看本文章

在pom文件中指定tools.jar依赖,具体参考:http://maven.apache.org/general.html#tools-jar-dependency :

[html]  view plain copy
 
  1. <profiles>  
  2.   <profile>  
  3.     <id>default-tools.jar</id>  
  4.     <activation>  
  5.       <property>  
  6.         <name>java.vendor</name>  
  7.         <value>Sun Microsystems Inc.</value>  
  8.       </property>  
  9.     </activation>  
  10.     <dependencies>  
  11.       <dependency>  
  12.         <groupId>com.sun</groupId>  
  13.         <artifactId>tools</artifactId>  
  14.         <version>1.6</version>  
  15.         <scope>system</scope>  
  16.         <systemPath>${java.home}/../lib/tools.jar</systemPath>  
  17.       </dependency>  
  18.     </dependencies>  
  19.   </profile>  
  20. </profiles>  


其中<version/>的value应该替换为你的jdk的版本。

猜你喜欢

转载自blueheart2008.iteye.com/blog/1886863