xmlbeans-maven-plugin找不到javac [英] xmlbeans-maven-plugin not finding javac

查看:382
本文介绍了xmlbeans-maven-plugin找不到javac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to setup xmlbeans-maven-plugin 2.3.3 in my Eclipse and while everything seems to go OK, It fails with an java.io.IOException due to inability to find the file C:\Users\Daniel\Workspace\MyProject\javac.

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

This is strange because javac is on the system's %PATH% so why would it try to find it in %PROJECT_LOC%?

我发现了此问题描述,听起来与我的非常相似,但我将其放置在JDK路径位于所有其他路径的前面,这无济于事.

I found this problem description which sounds very similar to mine, but I placed the JDK path in front of all other paths and that didn't help.

有什么主意如何告诉xmlbeans-maven-plugin 在哪里寻找javac?

Any idea how to tell the xmlbeans-maven-plugin where to look for javac?

更新1:我尝试通过简单地将javac.exe复制到项目目录中来解决此问题,至少现在它找到了,但是问题继续进行:

UPDATE 1: I tried working around this problem by simply copying javac.exe to the project's directory and at least it now finds it but the problem moved forward to:

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.

任何可以帮助提出正确解决方案的见解(例如

Any insight that could help come up with the correct solution to this (e.g. something in .m2/settings.xml?) would be appreciated.

更新2:我还尝试了

UPDATE 2: I also tried this little solution I found in my searches:

<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系统找不到指定的文件".

But that didn't help the plugin find javac. It still complains about "The system cannot find the file specified" for javac.exe.

推荐答案

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

Found the solution! In the project's pom.xml, simply add the following inside <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.如在该线程中所述.

Also, be sure to point the Window -> Preferences -> Java -> installed JREs to the JDK's, not JRE's: C:\Program Files (x86)\Java\jdk1.6.0_37. As described in this thread.

这篇关于xmlbeans-maven-plugin找不到javac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆