我试图从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,据我所知... –