在Eclipse环境下,使用Maven进行deploy时发现报了该错误:Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre6\..\lib\tools.jar.
我的方法:
在pom.xml文件里添加如下:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<showDeprecation>false</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<connectionType>developerConnection</connectionType>
<username>${username}</username>
<password>${password}</password>
<message>job-app</message>
<workingDirectory>src/</workingDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<tags>
<tag>
<name>func</name>
<placement>a</placement>
<head>功能介绍</head>
</tag>
<tag>
<name>param</name>
<placement>a</placement>
<head>请求参数</head>
</tag>
<tag>
<name>bean</name>
<placement>a</placement>
<head>bean</head>
</tag>
<tag>
<name>date</name>
<placement>a</placement>
<head>日期</head>
</tag>
</tags>
</configuration>
</plugin>
<!-- 热部署,发布到tomcat -->
<!-- goals: tomcat7:redeploy -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>90</port>
<path>/</path>
<url>http://192.168.0.6:90/manager/text</url>
<server>tomcat</server>
<username>admin</username>
<password>admin</password>
<uriEncoding>utf-8</uriEncoding>
<!-- <contextFile>src/main/context/context.xml</contextFile> -->
<!-- 如果server.xml配了,则其他所有配置都会失效,包括context.xml -->
<!-- <serverXml>src/main/context/server.xml</serverXml> -->
<!-- <contextReloadable>true</contextReloadable> -->
<!-- <backgroundProcessorDelay>5</backgroundProcessorDelay> -->
<!-- <additionalConfigFilesDir>${baseDir}/src/main/context</additionalConfigFilesDir> -->
</configuration>
</plugin>
</plugins>
</build>
网上的方法:
在Eclipse环境下,使用Maven进行deploy时发现报了该错误:Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre6\..\lib\tools.jar.
解决办法:
点击Eclipse菜单:Window->Preferences->Java->Installed JREs,选择右侧的Edit来修改JREs,之前我的JRE home设置的是:C:\Program Files\Jave\jre6,这个位置下是没有tools.jar包的,修改成:C:\Program Files\Java\jdk1.6.0_25,然后点击弹出窗口的Finish按钮和主页面中的OK按钮,则问题解决。