我試圖從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安裝:
您是否嘗試過'Eclipse'的'mvn clean compile'? –
eclipse中的settings.xml與命令行中使用的settings.xml相同嗎? – drgn
是的,我已經嘗試** mvn乾淨的編譯**序列,也與之間的「Maven更新」。 @drgn你是什麼意思?當我通過終端執行Maven時,它使用的唯一文件是pom.xml,據我所知... –