xmlbeans-maven-plugin 没有找到 javac [英] xmlbeans-maven-plugin not finding javac
问题描述
我正在尝试设置 xmlbeans-maven-plugin 2.3.3 在我的 Eclipse 中,虽然一切似乎都正常,但由于无法找到文件 C:UsersDanielWorkspaceMyProjectjavac
,它失败并出现 java.io.IOException.>
这很奇怪,因为 javac 是在系统的%PATH% 那么它为什么要尝试在 %PROJECT_LOC% 中找到它?
我发现这个问题描述,这听起来与我的非常相似,但我把JDK 路径在所有其他路径之前,但没有帮助.
知道如何告诉xmlbeans-maven-plugin
在哪里寻找javac
?>
更新 1: 我尝试通过简单地将 javac.exe
复制到项目目录来解决这个问题,至少它现在找到了,但问题转移到了:
java.lang.NoClassDefFoundError: com/sun/tools/javac/Main引起:java.lang.ClassNotFoundException:com.sun.tools.javac.Main在 java.net.URLClassLoader$1.run(Unknown Source)在 java.security.AccessController.doPrivileged(Native Method)在 java.net.URLClassLoader.findClass(Unknown Source)在 java.lang.ClassLoader.loadClass(来源不明)在 sun.misc.Launcher$AppClassLoader.loadClass(来源不明)在 java.lang.ClassLoader.loadClass(来源不明)线程main"中的异常找不到主类:com.sun.tools.javac.Main.程序将会退出.
任何有助于提出正确解决方案的见解(例如.m2/settings.xml?) 将不胜感激.
更新 2: 我也试过 这个小解决方案 我在搜索中发现:
<localRepository>c:maven
epository</localRepository><配置><编译器>C:Program Files (x86)Javajdk1.6.0_37injavac.exe</compiler></配置></设置>
但这并没有帮助插件找到javac
.它仍然抱怨 javac.exe 的系统找不到指定的文件".
找到解决方案!在项目的 pom.xml中,只需在
中添加以下内容:
C:Program Files (x86)Javajdk1.6.0_37injavac.exe</compiler>
即
<插件><groupId>org.codehaus.mojo</groupId><artifactId>xmlbeans-maven-plugin</artifactId><version>2.3.3</version><执行><执行><目标><goal>xmlbeans</goal></目标></执行></执行><继承的>真</继承的><配置><schemaDirectory>${basedir}/src/main/xsd</schemaDirectory><编译器>C:Program Files (x86)Javajdk1.6.0_37injavac.exe</compiler></配置></插件>
另外,一定要指向Window ->首选项 ->Java ->将 JRE
安装到 JDK,而不是 JRE:C:Program Files (x86)Javajdk1.6.0_37
.如本主题中所述.
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:UsersDanielWorkspaceMyProjectjavac
.
This is strange because javac is on the system's %PATH% so why would it try to find it in %PROJECT_LOC%?
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.
Any idea how to tell the xmlbeans-maven-plugin
where to look for javac
?
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.
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
epository</localRepository>
<configuration>
<compiler>C:Program Files (x86)Javajdk1.6.0_37injavac.exe</compiler>
</configuration>
</settings>
But that didn't help the plugin find javac
. It still complains about "The system cannot find the file specified" for javac.exe.
Found the solution! In the project's pom.xml, simply add the following inside <configuration>
:
<compiler>C:Program Files (x86)Javajdk1.6.0_37injavac.exe</compiler>
i.e.
<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)Javajdk1.6.0_37injavac.exe</compiler>
</configuration>
</plugin>
Also, be sure to point the Window -> Preferences -> Java -> installed JREs
to the JDK's, not JRE's: C:Program Files (x86)Javajdk1.6.0_37
. As described in this thread.
这篇关于xmlbeans-maven-plugin 没有找到 javac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!