Missing artifact com.sun:tools:jar:1.5.0 Maven依赖管理pom.xml中添加struts2-core包后报错的解决办法

方法一:

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

 

 

-vm
C:\Program Files\Java\jdk1.6.0_45\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.6

 

 

 

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

 

 

方法二:

 

在pom文件中指定tools.jar依赖

 

 

 <dependency>  
        <groupId>com.sun</groupId>  
        <artifactId>tools</artifactId>  
        <version>1.6</version>  
        <scope>system</scope>  
        <systemPath>C:/Program Files/Java/jdk1.6.0_45/lib/tools.jar</systemPath>  
 </dependency><dependency>  
        <groupId>com.sun</groupId>  
        <artifactId>tools</artifactId>  
        <version>1.6</version>  
        <scope>system</scope>  
        <systemPath>C:/Program Files/Java/jdk1.6.0_45/lib/tools.jar</systemPath>  
 </dependency>


其中<version/>的value应该替换为你的jdk的版本。 当然这种解决方式会有问题,如果生产机的jdk安装路径不同,那就会有问题。

 

 

 

 

 

 

方法三:

 去掉依赖

 

<exclusions>
	<exclusion>
		<groupId>com.sun</groupId>
		<artifactId>tools</artifactId>
	</exclusion>
</exclusions>	<exclusion>
		<groupId>com.sun</groupId>
		<artifactId>tools</artifactId>
	</exclusion>
</exclusions>

 

 

 

 

 

eclipse.ini配置原文

eclipse.ini

Overview

Eclipse startup is controlled by the options in $ECLIPSE_HOME/eclipse.ini. If $ECLIPSE_HOME is not defined, the default eclipse.ini in your Eclipse installation directory (or in the case of Mac, theEclipse.app/Contents/MacOS directory) is used.

eclipse.ini is a text file containing command-line options that are added to the command line used when Eclipse is started up. There are many options available, please see here.

Important:

  1. You can, and should, experiment with changes to the launch command from your Command Prompt/Terminal before changing the eclipse.ini itself.
  2. Each option and each argument to an option must be on its own line.
  3. All lines after -vmargs are passed as arguments to the JVM, so all arguments and options for eclipse must be specified before -vmargs (just like when you use arguments on the command-line)
  4. Any use of -vmargs on the command-line replaces all -vmargs settings in the .ini file unless --launcher.appendVmargs is specified either in the .ini file or on the command-line. (doc)
  5. -XX VM arguments are subject to change without notice, even during minor updates. If the JVM keeps exiting with code 2 instead of starting Eclipse, try removing them.
  6. Make a backup--keep a copy of the original contents on hand so you don't break your installation and have to download it all again.

 

By default, eclipse.ini looks something like this (the exact contents will vary based on operating system and which Eclipse package you have):

-startup
../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.100.v20110502
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m

Among other things, this sets the heap space to 40MB initially and a maximum of 512MB, and also specifies a maximum PermGen size of 256MB. A max heap of 512MB might be OK for some users, but it's often necessary to bump that value up for large project sets or when some third-party plugins are installed.

Specifying the JVM

One of the most recommended options to use is to specify a specific JVM for Eclipse to run on. Doing this ensures that you are absolutely certain which JVM Eclipse will run in and insulates you from system changes that can alter the "default" JVM for your system. Many a user has been tripped up because they thought they knew what JVM would be used by default, but they thought wrong. eclipse.ini lets you be CERTAIN.

The following examples of eclipse.ini demonstrate correct usage of the -vm option.

Note the format of the -vm option - it is important to be exact:

  • The -vm option and its value (the path) must be on separate lines.
  • (译文) -vm 参数和它对应的value必须单独一行。
  • The value must be the full absolute or relative path to the Java executable, not just to the Java home directory.
  • (译文)-vm的值必须是java可执行文件的绝对路径或相对路径,而不仅仅是Java安装主目录文件夹路径。
  • The -vm option must occur after the other Eclipse-specific options (such as -product--launcher.*, etc), but before the -vmargs option, since everything after -vmargs is passed directly to the JVM.
  • (译文)-vm 配置参数必须出现在Eclipse特定配置参数之后(例如-product, --launcher.*,等),但是必须出现在 -vmargs 配置参数前,因为 -vmargs 之后的所有内容都直接传递到JVM。
  • For the 32-bit Eclipse executable (eclipse.exe on Windows) a 32-bit JVM must be used and for the 64-bit Eclipse executable a 64-bit JVM must be used. 32-bit Eclipse will not work with a 64-bit JVM.

Here is an example of what eclipse.ini might look like on a Windows system after you've added the -vm argument and increased the maximum heap space:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:\Java\JDK\1.8\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx1024m

Remember that the exact values will differ slightly depending on operating system and Eclipse package.

-vm value: Windows Example

This is how the -vm argument might look on Windows (your exact path to javaw.exe could be different, of course):

-vm
C:\jdk1.7.0_21\bin\javaw.exe 


An alternative way is to insert the following VM option before the -vmargs option in the Eclipse shortcut's properties (edit the field Target inside the "Shortcut" tab):

-vm C:\jdk1.7.0_21\bin\javaw.exe 

or

-vm C:\jdk1.7.0_21\jre\bin\java.exe

This might not work on all systems. If you encounter "Java was started but returned exit code=1" error while starting the eclipse, modify the -vm argument to point to jvm.dll (exact path could be different):

-vm
C:\Development\Java\64bit\jdk1.7.0_09\jre\bin\server\jvm.dll

-vm value: Linux Example

This is how the -vm argument might look on Linux (your exact path to java could be different, of course):

-vm
/opt/sun-jdk-1.6.0.02/bin/java

-vm value: Mac OS X Example

On a Mac OS X system, you can find eclipse.ini by right-clicking (or Ctrl+click) on the Eclipse executable in Finder, choose Show Package Contents, and then locate eclipse.ini in theEclipse folder under Contents. The path is often

/Applications/Eclipse.app/Contents/Eclipse/eclipse.ini

For versions of Mac OS X 10.7+ the location is something like /Library/Java/JavaVirtualMachines/<JRE_NAME>/Contents/Home/bin

For example, the latest JDK 1.8 (as of July 2015) is /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin

For standard Mac Java installations and so you don't have to continually update the setting when you install new Java VMs, set the -vm flag to simply /usr/bin:

-vm
/usr/bin

Here is additional information:

Perhaps the best way to determine the location for the JDK you want to use is with the utility

/usr/libexec/java_home --verbose

From the list produced by that command, select the JDK you want to use and put that path into the eclipse.ini file, making sure to append /bin/java to the path (eg,/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java

Note that the full path can either include java or not. For example, the following will both work:

-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin
-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java

 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值