【问题标题】:xmlbeans-maven-plugin not finding javacxmlbeans-maven-plugin 找不到 javac
【发布时间】:2012-12-04 14:54:45
【问题描述】:

我正在尝试在我的 Eclipse 中设置 xmlbeans-maven-plugin 2.3.3,虽然一切似乎都正常,但由于无法找到文件 C:\Users\Daniel\Workspace\MyProject\javac,它失败并出现 java.io.IOException。

这很奇怪,因为 javac is 在系统的 %PATH% 上,为什么它会尝试在 %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。它仍然抱怨 javac.exe 的“系统找不到指定的文件”。

【问题讨论】:

    标签: maven javac m2e xmlbeans xmlbeans-maven-plugin


    【解决方案1】:

    找到了解决方案!在项目的 pom.xml 中,只需在&lt;configuration&gt; 中添加以下内容:

    <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 -&gt; Preferences -&gt; Java -&gt; installed JREs 指向 JDK,而不是 JRE:C:\Program Files (x86)\Java\jdk1.6.0_37。如in this thread所述。

    【讨论】:

      猜你喜欢
      • 2011-06-06
      • 2012-01-07
      • 1970-01-01
      • 2019-01-17
      • 1970-01-01
      • 1970-01-01
      • 2018-11-22
      • 2015-02-25
      • 1970-01-01
      相关资源
      最近更新 更多