我正在尝试在我的Eclipse中设置xmlbeans-maven-plugin 2.3.3,虽然一切似乎都进行得很顺利,但是由于找不到文件C:\Users\Daniel\Workspace\MyProject\javac,java.io.IOException失败了。
这很奇怪,因为javac http://wiki.apache.org/xmlbeans/XmlBeansFaq#scompFindingJavac位于系统的%PATH%上,那么它为什么要在%PROJECT_LOC%中找到它呢?
我发现了这个问题的描述,听起来与我的非常相似,但我将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/setings.xml中的某些东西?)我会很感激的。
更新2: --我还在搜索中找到了这个小小的解决方案:
<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的“系统找不到指定的文件”。
发布于 2012-12-04 16:12:05
找到解决办法了!在项目的 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。正如所描述的在这个线程中。
https://stackoverflow.com/questions/13705670
复制相似问题