gpt4 book ai didi

java - maven-jaxb2-plugin:即使 xsd 和 xjb 文件位于同一位置,解析架构位置也会出错

转载 作者:太空宇宙 更新时间:2023-11-04 11:24:39 27 4
gpt4 key购买 nike

我有一个 pom.xml ,如下所示:-

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.eros</groupId>
<artifactId>model</artifactId>
<version>0.001-SNAPSHOT</version>
</parent>

<artifactId>nato-model</artifactId>
<packaging>jar</packaging>
<name>nato-model</name>

<dependencies>
<dependency>
<groupId>com.eros</groupId>
<artifactId>core-model</artifactId>
<version>${main.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<configuration>
<verbose>false</verbose>
<removeOldOutput>false</removeOldOutput>
<markGenerated>true</markGenerated>
</configuration>

<executions>

<execution>
<id>b</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>com.eros.model.nato.n5k</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/jaxb</generateDirectory>
<schemaDirectory>
${project.basedir}/../../schema/src/main/xsd/com/eros/model/nato/custom_xsds
</schemaDirectory>
<schemaIncludes>
<include>n5k.xsd</include>
</schemaIncludes>
<bindingDirectory>${project.basedir}/../../schema/src/main/xsd/com/eros/model/nato/custom_xsds</bindingDirectory>
<bindingIncludes>
<include>n5k.xjb</include>
</bindingIncludes>
<strict>false</strict>
<forceRegenerate>true</forceRegenerate>
</configuration>
</execution>
<execution>
<id>n7k</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>com.eros.model.nato.n7k</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/jaxb</generateDirectory>
<schemaDirectory>
${project.basedir}/../../schema/src/main/xsd/com/eros/model/nato/custom_xsds
</schemaDirectory>
<schemaIncludes>
<include>n7k.xsd</include>
</schemaIncludes>
<bindingDirectory>${project.basedir}/../../schema/src/main/xsd/com/eros/model/nato/custom_xsds</bindingDirectory>
<strict>false</strict>
<forceRegenerate>true</forceRegenerate>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>

我的 n5k.xjb 文件如下所示:-

<?xml version="1.0" ?>
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" schemaLocation="./n5k.xsd">
<jaxb:bindings>
<jaxb:globalBindings typesafeEnumMaxMembers="1024"/>
</jaxb:bindings>
</jaxb:bindings>

我的 n7k.xjb 如下所示:-

<?xml version="1.0" ?>
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" schemaLocation="n7k.xsd">
<jaxb:bindings>
<jaxb:globalBindings typesafeEnumMaxMembers="1024"/>
</jaxb:bindings>
</jaxb:bindings>

但是在编译时我收到以下错误:-

Error while parsing schema(s).Location [ file:/Users/tuk/code/github/eros/main/schema/src/main/xsd/com/eros/model/nato/custom_xsds/n5k.xjb{2,102}].
com.sun.istack.SAXParseException2; systemId: file:/Users/tuk/code/github/eros/main/schema/src/main/xsd/com/eros/model/nato/custom_xsds/n5k.xjb; lineNumber: 2; columnNumber: 102; "file:/Users/tuk/code/github/eros/main/schema/src/main/xsd/com/eros/model/nato/custom_xsds/n5k.xsd" is not a part of this compilation. Is this a mistake for "file:/Users/tuk/code/github/eros/main/schema/src/main/xsd/com/eros/model/nato/custom_xsds/n7k.xsd"

有人可以让我知道我做错了什么吗?

环境:-

  • Java 8
  • Maven 3.5

最佳答案

我认为问题出在n7k.xsd的编译上。在第二次执行中,您没有配置 bindingIncludes。显然,n7k.xjbn5k.xjb 都被使用。 n5k.xjb 引用了 n5k.xsd,它不属于此编译的一部分。

要解决此问题,请尝试添加:

<bindingIncludes>
<include>n7k.xjb</include>
</bindingIncludes>

到第二次执行的配置。

关于java - maven-jaxb2-plugin:即使 xsd 和 xjb 文件位于同一位置,解析架构位置也会出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44504027/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com