Eclipse 运行使用指定的 JVM - m2eclipse 插件找不到 com.sun 的 default-tools.jar 的解决方案...

用了m2eclipse 插件后,使用struts2时,需要依赖 com.sun 的 default-tools.jar,见pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>cn.tianxing.gehouse.admin</groupId>
  <artifactId>admin.gehouse.cn</artifactId>
  <name>admin.gehouse.cn</name>
  <version>0.0.1</version>
  <description>admin.gehouse.cn</description>
  <url>http://admin.gehouse.cn</url>
  <issueManagement>
    <system>jira</system>
    <url>http://jira.gehouse.cn:8080/BrowseProject.jspa?id=10000</url>
  </issueManagement>
  <ciManagement>
    <system>continuum</system>
    <url>http://ci.gehouse.cn:8090/continuum</url>
    <notifiers>
      <notifier>
        <type>msn</type>
        <sendOnSuccess>false</sendOnSuccess>
        <sendOnWarning>false</sendOnWarning>
        <configuration>
          <address>kylindai@hotmail.com</address>
        </configuration>
      </notifier>
      <notifier>
        <type>msn</type>
        <sendOnSuccess>false</sendOnSuccess>
        <sendOnWarning>false</sendOnWarning>
        <configuration>
          <address>larrin2002@msn.com</address>
        </configuration>
      </notifier>
      <notifier>
        <type>msn</type>
        <sendOnSuccess>false</sendOnSuccess>
        <sendOnWarning>false</sendOnWarning>
        <configuration>
          <address>manjingtou-ren@hotmail.com</address>
        </configuration>
      </notifier>
    </notifiers>
  </ciManagement>
  <inceptionYear>2007-05</inceptionYear>
  <developers>
    <developer>
      <name>kylin.dai</name>
      <email>kylin.dai@gehouse.cn</email>
    </developer>
    <developer>
      <name>larrin.luo</name>
      <email>larrin.luo@gehouse.cn</email>
    </developer>
    <developer>
      <name>jason.ren</name>
      <email>jason.ren@gehouse.cn</email>
    </developer>
  </developers>
  <scm>
    <connection>scm:svn:svn://svn.gehouse.cn/sandbox/kylin/admin.gehouse.cn/trunk</connection>
  </scm>
  <organization>
    <name>gehouse.cn</name>
    <url>http://www.gehouse.cn</url>
  </organization>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id> default-tools.jar</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId> com.sun</groupId>
          <artifactId> tools</artifactId>
          <version> 1.5.0</version>
          <scope> system</scope>
          <systemPath> ${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
  <dependencies>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.14</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
    </dependency>
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>com.ibatis</groupId>
      <artifactId>ibatis</artifactId>
      <version>2.3.0.667</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.1</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.extremecomponents</groupId>
      <artifactId>extremecomponents</artifactId>
      <version>1.0.1</version>
    </dependency>
    <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.2.1</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
      <version>2.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-mock</artifactId>
      <version>2.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <version>2.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-core</artifactId>
      <version>2.0.6</version>
    </dependency>
  </dependencies>
  <reporting>
    <plugins>
      <plugin>
        <artifactId>maven-changelog-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-pmd-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-changes-plugin</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <report>jira-report</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
</project>


这个pom.xml 在eclipse里加载的时候总是报告:

Missing:
1) com.sun:tools:jar:1.4.2
Try downloading the file manually from the project website.
Then, install it using the command:

mvn install:install-file -DgroupId=com.sun -DartifactId=tools \
-Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file
Path to dependency:

原来,是${java.home}在作怪,eclipse 没有使用 JAVA_HOME
默认,eclipse 使用 C:\windows\system32\javaw.exe 作为 JVM,当然找不到tools.jar

解决方法如下:
修改 eclipse.exe 目录下的 eclipse.ini 指定vm,加入红色黑体字部分,注意 -vm后面不能有空格。

-vm
D:\Program Files\Java\jdk1.6.0_01\bin\javaw.exe

-vmargs
-Xms128m
-Xmx512m

再次启动 eclipse,问题解决。

上面的pom.xml文件,也是一个 Mavne2 & Continuum 的例子,由我写的 Maven2 & Continuum 持续整合 (3),发布时,网络故障丢失了,也不打算重新再写一篇了,上述的pom.xml,可以在continuum的 add maven2 projects 里,添加使用,设好 scheduler,可以设1小时 build 一次,半小时 test 一次,等不同的任务。



 

转载于:https://www.cnblogs.com/kylindai/archive/2007/05/09/740715.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值