2016-03-09 209 views
1

我试图从Eclipse的火星(4.5.1)的内部编译Maven项目时有问题。的Maven的Eclipse +编译失败,在终端Maven的编译工作

规格:

  • 的Win 7 SP1 64位
  • JDK 64 1.8.0_72
  • 的Eclipse 4.5.1的x64
  • 的Maven 3.3.9

我相信这是一个Eclipse的Maven插件的互动问题,因为我能够执行从终端的目标,如:

mvn clean compile 

mvn generate-sources 

mvn install 

在Eclipse,当我在项目名称上单击鼠标右键,选择Maven的安装作为执行目标,我收到以下错误:

Scanning for projects

...

Building project-name-1.0-SNAPSHOT ...

[WARNING] The POM for com.sun.xml.ws:jaxws-rt:jar:2.2.10 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[INFO] --- jaxws-maven-plugin:2.3:wsimport (default) @ project-name

[WARNING] The POM for com.sun.xml.ws:jaxws-tools:jar:2.2.10 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[INFO] Processing: file:/C:/project-name/src/main/resources/file.wsdl [INFO] jaxws:wsimport args: [-keep, -s, C:\project-name\target\generated-sources\wsimport, -d, C:\project-name\target\classes, -encoding, UTF-8, -Xnocompile, "file:/C:/project-name/src/main/resources/file.wsdl"]

[WARNING] Failed to build parent project for com.sun.xml.ws:bundles:pom:2.2.10

[WARNING] Failed to build parent project for com.sun.xml.ws:jaxws-tools:pom:2.2.10

[WARNING] Invalid POM for com.sun.xml.ws:jaxws-tools:jar:2.2.10, transitive dependencies (if any) will not be available, enable debug logging for more details

[INFO] BUILD FAILURE

...

[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (default) on project project-name: Execution default of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport failed: String index out of range: -1 -> [Help 1]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

但是,如果我从执行mvn install终端,目标成功! 我想我已经全部安装在Eclipse中必要的Maven插件和pom.xml文件是正确的,因为通过终端的一切似乎工作。 希望有人能够暗示这个问题。

编辑︰虽然mvn install在Eclipse中失败,如果我在Eclipse中创建一个Maven构造配置与目标mvn install -e,问题不会发生。传递这个标志可以解决这个问题。

编辑:我贴上特定的pom.xml部分触发Eclipse中的问题(粗体文字是什么Eclipse在红色下划线):

<project 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/maven-v4_0_0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 
    <!-- http://maven.apache.org/pom.html#Quick_Overview --> 

    <groupId>group.name</groupId> 
    <artifactId>project-name</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>${project.artifactId}</name> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 

     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 

     <wsdl.directory>${basedir}/../project-dep/src/main/resources</wsdl.directory> 
     <wsdl.filename>file.wsdl</wsdl.filename> 

     <mainclass>group.name.subname.TestApplication</mainclass> 

     <ws.url>http://localhost:8081/sample-ws/endpoint</ws.url> 

     <ws.name>Sample</ws.name> 
     <uddi.url>http://localhost:9090</uddi.url> 
    </properties> 

    <dependencies> 
     <!-- JAX-WS --> 
     <dependency> 
      <groupId>com.sun.xml.ws</groupId> 
      <artifactId>jaxws-rt</artifactId> 
      <version>2.2.10</version> 
     </dependency> 
     <!-- UDDI --> 
     <dependency> 
      <groupId>group.name.uddi</groupId> 
      <artifactId>uddi-naming</artifactId> 
      <version>1.0</version> 
     </dependency> 
     <!-- SOAP Handlers --> 
     <dependency> 
      <groupId>group.name.soap</groupId> 
      <artifactId>ws-handlers</artifactId> 
      <version>1.0</version> 
     </dependency> 
     <!-- JMockit - must appear before JUnit --> 
     <dependency> 
      <groupId>org.jmockit</groupId> 
      <artifactId>jmockit</artifactId> 
      <version>1.21</version> 
      <scope>test</scope> 
     </dependency> 
     <!-- JUnit --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.12</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <resources> 
      <resource> 
       <directory>src/main/resources</directory> 
       <filtering>true</filtering> 
      </resource> 
     </resources> 
     <testResources> 
      <testResource> 
       <directory>src/test/resources</directory> 
       <filtering>true</filtering> 
      </testResource> 
     </testResources> 
     <plugins> 
      <plugin> 
       <groupId>org.jvnet.jax-ws-commons</groupId> 
       <artifactId>jaxws-maven-plugin</artifactId> 
       <version>2.3</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>wsimport</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <!-- https://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html --> 
        <wsdlDirectory>${wsdl.directory}</wsdlDirectory> 
        <wsdlFiles> 
         <wsdlFile>${wsdl.filename}</wsdlFile> 
        </wsdlFiles> 
       </configuration> 
       <dependencies> 
        <dependency> 
         <groupId>com.sun.xml.ws</groupId> 
         <artifactId>jaxws-tools</artifactId> 
         <version>2.2.10</version> 
        </dependency> 
       </dependencies> 
      </plugin> 
      <plugin> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <version>2.19.1</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>integration-test</goal> 
          <goal>verify</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.4.0</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>java</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <!-- to prevent deprecation warning: --> 
        <killAfter>-1</killAfter> 
        <mainClass>${mainclass}</mainClass> 
        <arguments> 
         <argument>${ws.url}</argument> 
        </arguments> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>appassembler-maven-plugin</artifactId> 
       <version>1.10</version> 
       <executions> 
        <execution> 
         <phase>install</phase> 
         <goals> 
          <goal>assemble</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <programs> 
         <program> 
          <mainClass>${mainclass}</mainClass> 
          <id>${project.artifactId}</id> 
         </program> 
        </programs> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

这是我在Eclipse中Maven安装:

enter image description here

+0

您是否尝试过'Eclipse'的'mvn clean compile'? –

+0

eclipse中的settings.xml与命令行中使用的settings.xml相同吗? – drgn

+0

是的,我已经尝试** mvn干净的编译**序列,也与之间的“Maven更新”。 @drgn你是什么意思?当我通过终端执行Maven时,它使用的唯一文件是pom.xml,据我所知... –

回答

2

入住Maven > User SettingsUser Settings点比你的Maven相同的归档。

您是否试过EMBBEDED?

+0

这个伎俩。这触发了Eclipse中的内部刷新,现在它可以工作。切换到'EMBEDDED',然后回到我的个人安装做到了。 –

0

我不能告诉你具体情况,但我已经看到两种情况,其中Eclipse工作/ cmdline不是,反之亦然,特别是复杂的泛型和深层嵌套接口。

对我来说,Eclipse似乎正在做一些自己的解析/字节代码生成,也许使用工作表下的tools.jar,但我从来没有深入过深(特别是因为我更喜欢IntelliJ,它使用native maven和JVM,并没有这个问题)。

最终,你不能相信的Eclipse,就知道肯定是CMDLINE代的唯一途径(如你所经历的)。

+0

请检查原始问题的底部编辑,我认为这符合你的写作。你会建议更深入的调查? –

+0

沟蚀。对不起,这是一把带有许多刀片的瑞士军刀,其中一些刀片不能很好地工作。我在Maven,java编译和git集成方面遇到了问题,并将每个人都远离它。 –

+0

我明白你的建议。但是,Eclipse目前是强制性的。 Scott,你是否有任何额外的建议开始挖掘Eclipse执行堆栈,试图了解它没有从Maven配置中正确读取? –

3

首先,如果在控制台中正常工作,你有一个项目,是可以在每个IDE的谁支持Maven项目importe。这是一个好消息。

其次,检查选择的maven配置文件(存储库配置,...)在控制台和Eclipse中是否相同。

然后,你可以检查你的配置在settings.xml中(在你的。M2目录)

也许这个以前的答案可以帮助过: Maven ignores execution configuration

+0

不幸的是,这是一个涉及Eclipse的问题。在终端中,Maven的行为如预期。 –

0

我认为你必须重新组织pom.xml

<dependencies> 
    <dependency> 
    <groupId>com.sun.xml.ws</groupId> 
    <artifactId>jaxws-tools</artifactId> 
    <version>2.2.10</version> 
    </dependency> 
</dependencies> 

<build></build>哪个是假的。也有错误,我们可以看到,这个问题是:

Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport

所以他不明白这里的<goal>不知道。并且顺便说一句在插件的最后,你必须添加一个小号<plugins>

<plugins> 
      <plugin> 
       <groupId>org.jvnet.jax-ws-commons</groupId> 
       <artifactId>jaxws-maven-plugin</artifactId> 
       <version>2.3</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>wsimport</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <!-- https://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html --> 
        <wsdlDirectory>${wsdl.directory}</wsdlDirectory> 
        <wsdlFiles> 
         <wsdlFile>${wsdl.filename}</wsdlFile> 
        </wsdlFiles> 
       </configuration> 
       <dependencies> 
        <dependency> 
         <groupId>com.sun.xml.ws</groupId> 
         <artifactId>jaxws-tools</artifactId> 
         <version>2.2.10</version> 
        </dependency> 
       </dependencies> 
      </plugin> 
      <pluginS> 

我有jaxws-maven-plugin合作过,但像这样的<groupId>另一名:

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>jaxws-maven-plugin</artifactId> 
       <version>1.12</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>wsimport</goal> 
         </goals> 
         <configuration> 
          <wsdlLocation>http://mysite/firstwsdl.asmx?wsdl</wsdlLocation> 
          <packageName>com</packageName> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 

试试这个,希望这会有所帮助。

+0

Hohenheim,感谢您的建议,但我无法理解其中的一些: - 标记在我的pom.xml中没有缺失的字符。根据官方的Maven文档,在内可以有<依赖关系>:https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_dependencies_Tag - 移动了JAX-WS Maven插件从codehaus mojo项目,但到2007年,它转移到jax-wx-commons(https://jax-ws-commons.java.net/jaxws-maven-plugin/),因此在 ...标签。 –

+0

此外,这个pom.xml与终端中的'mvn install'完美搭配,这是一个特定于Eclipse的Maven交互问题。 –