2016-03-09 208 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交互問題。 –