【问题标题】:maven-jaxb2-plugin class generation from xsd (Version Error)从 xsd 生成 maven-jaxb2-plugin 类(版本错误)
【发布时间】:2015-09-20 21:28:15
【问题描述】:

我的 pom.xml,

<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>

<groupId>com.rajkishan</groupId>
<artifactId>RESTful-Swagger</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>

<name>RESTful-Swagger</name>

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.2.4.RELEASE</version>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <start-class>com.rajkishan.Application</start-class>
</properties>

 <dependencies>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>com.mangofactory</groupId>
    <artifactId>swagger-springmvc</artifactId>
    <version>1.0.2</version>
</dependency>

</dependencies>

 <build>
<plugins>

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>

    <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.12.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>src/main/resources</schemaDirectory>
                <schemaIncludes>
                    <include>Greeting.xsd</include>
                </schemaIncludes>
                <generatePackage>com.rajkishan.xmlgen</generatePackage>
            </configuration>
        </plugin>

</plugins>

当我在“Netbeans”中使用 maven 构建时,效果很好。

但是如果我在 Eclipse Luna 中使用,它会给出如下错误;

目标 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed 的执行默认值:执行 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12 时缺少必需的类.3:生成:com/sun/xml/bind/api/ErrorListener

但如果我将版本更改为0.12.1,它会起作用,如下所示;

<plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.12.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>src/main/resources</schemaDirectory>
                <schemaIncludes>
                    <include>Greeting.xsd</include>
                </schemaIncludes>
                <generatePackage>com.rajkishan.xmlgen</generatePackage>
            </configuration>
        </plugin>

谁能告诉我这里有什么问题?我错过了什么吗?

注意:我在 eclipse 中使用 jdk1.8。

【问题讨论】:

    标签: java xml maven xsd


    【解决方案1】:

    我遇到了同样的问题。 Eclipse 是使用 jre 启动的,而不是 jdk。将eclipse更改为从jdk开始后,它运行良好......

    希望对你有帮助。

    【讨论】:

      【解决方案2】:

      添加以下依赖并重试 -

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

      【讨论】:

      猜你喜欢
      • 2013-12-18
      • 2013-03-31
      • 2011-03-28
      • 1970-01-01
      • 1970-01-01
      • 2011-12-30
      • 1970-01-01
      • 1970-01-01
      • 2016-03-09
      相关资源
      最近更新 更多