尝试从WSDL文件生成时Maven有问题

时间:2015-02-13 14:09:49

标签: eclipse soap jaxb wsdl maven-jaxb2-plugin

我试图从wsdl文件生成源代码,但是我的pom.xml上一直出现错误,我认为这可能是我的问题?下面是我从我的pom和我的pom文件中得到的错误。此外,我无法使用" mvn clean install"来构建项目。我似乎只是因为没有真正原因而得到错误。

生成标记的错误:

Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate: com/sun/codemodel/CodeWriter
-----------------------------------------------------
realm =    plugin>org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3-715230752
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin/0.12.3/maven-jaxb2-plugin-0.12.3.jar
urls[1] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin-core/0.12.3/maven-jaxb2-plugin-core-0.12.3.jar
urls[2] = file:/C:/Users/Windows/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
urls[3] = file:/C:/Users/Windows/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar
urls[4] = file:/C:/Users/Windows/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar
urls[5] = file:/C:/Users/Windows/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar
urls[6] = file:/C:/Users/Windows/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
urls[7] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb22-plugin/0.12.3/maven-jaxb22-plugin-0.12.3.jar
urls[8] = file:/C:/Users/Windows/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
urls[9] = file:/C:/Users/Windows/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
urls[10] = file:/C:/Users/Windows/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 5
import: Entry[import org.sonatype.plexus.build.incremental from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.Scanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.DirectoryScanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.AbstractScanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------
 (org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate:default:generate-sources)

我的pom.xml文件:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.bigthunk</groupId>
        <artifactId>BigThunkCore</artifactId>
        <version>0.0.7-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.bigthunk</groupId>
        <artifactId>BigThunkWeb</artifactId>
        <version>0.0.4-SNAPSHOT</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <!-- tag::wsdl[] -->
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaLanguage>WSDL</schemaLanguage>
                <generatePackage>hello.wsdl</generatePackage>
                <forceRegenerate>true</forceRegenerate>
                <schemas>
                    <schema>
                        <url>http://172.19.137.21:8280/services/umarketsc?wsdl</url>
                    </schema>
                </schemas>
            </configuration>
        </plugin>
        <!-- end::wsdl[] -->
    </plugins>
</build>

<repositories>
    <repository>
        <id>project.local</id>
        <name>project</name>
        <url>file:${project.basedir}/repo</url>
    </repository>
    <repository>
        <id>spring-releases</id>
        <name>Spring Releases</name>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>

7 个答案:

答案 0 :(得分:34)

<plugins>标记括在<pluginManagement>标记内(详见How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds),为我解决了这个问题。

答案 1 :(得分:9)

将您的Java Path jre更改为您的jdk路径,它会没问题! 在Eclipse中,您还可以更改已安装的JRE&#34;到你的jdk。

希望它对你有用。

答案 2 :(得分:4)

在我的情况下,我通过更改JAXB规范版本来修复它,如插件wiki中所示:

https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-a-Specific-JAXB-Version

使用配置选项 specVersion = 2.0 或使用特定于版本的插件: maven-jaxb20-plugin

答案 3 :(得分:3)

对我来说,这是一个环境(java运行时)问题。通过在Windows命令提示符下启动eclipse,我可以在我的上下文中解决由m2e触发的类似问题: eclipse.exe -vm&#34; C:\ Program Files \ Java \ jdk1.8.0_25 \ bin \ javaw.exe&#34; (确保它来之前&#34; -vmargs&#34;) 然后我试图以同样的方式清理我的eclipse.ini从资源管理器启动eclipse,它确实有效。当我在Javavisual VM中查看eclipse命令时,我通过Jvisual vm看到eclipse看起来那样

eclipse.commands=-os
win32
...
-vm "C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe"
-vm C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll

最后一行不是来自我的eclipse.ini,而是附加了Eclipse启动器。在系统专业中:eclipse.vm = C:\ Program Files \ Java \ jre1.8.0_25 \ bin \ server \ jvm.dll 这看起来像#34;当从资源管理器&#34;启动时,Eclipse luna会在PATH上添加来自jre的参数来覆盖eclipse.ini ...环境中必须存在一些差异,可以解释不同的行为。过程

答案 4 :(得分:1)

我有这个问题,但我能够解决它:

  1. 我删除了所有单个JRE文件(以前版本和当前版本)
  2. 添加到“路径”int dataCount = 3500000; int propertyCount = 4; for (i=0; i<dataCount; i++) { unsigned int dataPointerOffset = i * propertyCount; // Notice pointer arithmetic. optimizer_backtest<<<32, 1024>>>(devData + dataPointerOffset, devStrategies, strategyCount, investment, profitability); } (我在Win10上工作)
  3. 利润。
  4. 问题出现在版本0.12.2 - 0.13.1上,它完全消失了。

答案 5 :(得分:0)

添加

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.11</version>
</dependency>

到你的pom,它包含了缺少的类,我修复了它。

答案 6 :(得分:0)

我个人使用sdkman来管理我的Java版本,并且在运行Maven命令之前从Java 11切换到8解决了这个问题。