java - 从 xsd 生成 maven-jaxb2-plugin 类(版本错误)

标签 java xml maven xsd

我的 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 中使用,它会给出如下错误;

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

最佳答案

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

希望对您有所帮助。

关于java - 从 xsd 生成 maven-jaxb2-plugin 类(版本错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31200017/

相关文章:

java - 子类成员变量对另一个子类的可见性

android - EditText 不得包含 < 字符

c# - 如何通过代理使用 .dtd 而不是使用 system.net.defaultproxy 来验证 xml

java - maven-shade-plugin:排除依赖项及其所有传递依赖项

java - 我应该在 TCP 服务器代码中对多种类型的请求使用命令模式吗?

java - Hibernate JPQL 返回 count(*) 查询的多个结果

java - 使用 Spring 引导将 list<object> 传递给 thymeleaf

java - 使用java将excel数据解析为xml

java - AspectJ @DeclareMixin,未由接口(interface)声明的方法不会被编织

css - 如何在 JSF 中使用来自 webjars.org 的 Font Awesome