2012-12-04 71 views
1

我想在我的Eclipse中设置xmlbeans-maven-plugin 2.3.3,虽然一切似乎都不错,但由于无法找到文件C:\Users\Daniel\Workspace\MyProject\javac而导致java.io.IOException失败。xmlbeans-maven-plugin找不到javac

这很奇怪,因为系统%PATH%上的javac is,为什么它会尝试在%PROJECT_LOC%中找到它?

我发现this problem description这听起来与我的非常相似,但是我将JDK路径放在所有其他路径的前面,这并没有帮助。

任何想法如何告诉xmlbeans-maven-plugin哪里寻找javac

更新1:我试图通过简单地复制javac.exe到项目的目录,至少它现在发现它,但问题向前推进,以解决此问题的工作:

java.lang.NoClassDefFoundError: com/sun/tools/javac/Main 
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
Exception in thread "main" Could not find the main class: com.sun.tools.javac.Main. Program will exit. 

任何了解,可以帮助来与正确的解决方案(例如在.m2/settings.xml?)将不胜感激。

更新2:我也试过this little solution我在搜索中发现:

<settings 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/xsd/settings-1.0.0.xsd"> 
    <localRepository>c:\maven\repository</localRepository> 
    <configuration> 
    <compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler> 
    </configuration> 
</settings> 

但是,这并没有帮助插件找到javac。它仍然抱怨“系统找不到指定的文件”for javac.exe。

回答

2

找到解决方案!在项目的 pom.xml中,只需添加内<configuration>如下:

<compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler> 

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>xmlbeans-maven-plugin</artifactId> 
      <version>2.3.3</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>xmlbeans</goal> 
        </goals> 
       </execution> 
      </executions> 
      <inherited>true</inherited> 
      <configuration> 
       <schemaDirectory>${basedir}/src/main/xsd</schemaDirectory> 
       <compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler> 
      </configuration> 
     </plugin> 

而且,务必将Window -> Preferences -> Java -> installed JREs指向JDK的,而不是JRE的:C:\Program Files (x86)\Java\jdk1.6.0_37。如所述in this thread