java - 从 XSD 模式生成 JAXB 类会导致奇怪的包结构
问题描述
使用以下插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
我从entity.xsd
放置在 中的 XSD 模式(比方说)生成类,/src/main/resources
具有命名空间定义的根元素在下面的示例中:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:webpage="https://www.mywebpage.com"
targetNamespace="https://www.mywebpage.com"
elementFormDefault="qualified">
...
</xs:schema>
在mvn clean install
上,生成的结构target/generated-sources/jaxb
非常奇怪:
target/generated-sources/jaxb
https
www_mywebpage
ObjectFactory.java
Entity.java
EntityDetailsRequest.java
EntityDetailsResponse.java
我期待的是:
target/generated-sources/jaxb
com.mywebpage
ObjectFactory.java
Entity.java
EntityDetailsRequest.java
EntityDetailsResponse.java
我做错了什么?
解决方案
我在 XSD 架构中有一个错误。maven-jaxb2-plugin
不承认,https
但只有http
.
我变了:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:webpage="https://www.mywebpage.com"
targetNamespace="https://www.mywebpage.com"
至:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:webpage="http://www.mywebpage.com"
targetNamespace="http://www.mywebpage.com"
生成的结构符合我的预期并在我的问题中描述。
推荐阅读
- python - 如何管理 Cygwin 中可能由 BLODA 引起的分叉错误?
- python-3.x - 当我期待错误原因时,为什么这种语言会返回数字 3
- azure - Azure.NotificationHubs 安装类中的“推送通道”指的是什么?
- javascript - Array 对象不是与 Object 不同吗(认为两者的 typeof 返回相同的值)?
- mysql - 从数据库中确定最有利可图的商店的功能
- ios - 如何将响应数据设置到 TodayExtension 小部件中
- python - 使用 scipy 和 Mathematica 求解多维非线性方程组的策略
- c++ - C++ API 的消费者驱动契约测试
- pyspark - 临时视图和临时视图有什么区别吗?
- python - _tkinter.TclError:未知选项“-d”