首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xmlbeans-maven-plugin找不到javac

xmlbeans-maven-plugin找不到javac
EN

Stack Overflow用户
提问于 2012-12-04 14:54:45
回答 1查看 3.2K关注 0票数 1

我正在尝试在我的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复制到项目的目录中来解决这个问题,至少现在它找到了,但是问题转移到:

代码语言:javascript
复制
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: --我还在搜索中找到了这个小小的解决方案

代码语言:javascript
复制
<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的“系统找不到指定的文件”。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-04 16:12:05

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

代码语言:javascript
复制
<compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler>

代码语言:javascript
复制
        <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。正如所描述的在这个线程中

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13705670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档