根据文档,可以这样做:
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.4.5</version>
<configuration>
<schemaLocation>src/main/conf</schemaLocation>
<includeSchemas>
<includeSchema>myschema.xsd</includeSchema>
</includeSchemas>
<options>
<package>my.package</package>
</options>
</configuration>
<executions>
<execution>
<goals>
<goal>schema-codegen</goal>
</goals>
</execution>
</executions>
</plugin>
但是你应该小心使用包名而不是来自 xsd 命名空间的默认值,因为如果你有多个命名空间,你可能会在生成的源代码中发生冲突。
您可以定义多个执行以具有具有不同包名称的不同模式。
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.4.5</version>
<executions>
<execution>
<id>schemata-a</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/conf-a</schemaLocation>
<includeSchemas>
<includeSchema>myschema.xsd</includeSchema>
</includeSchemas>
<options>
<package>my.package.a</package>
</options>
</configuration>
</execution>
<execution>
<id>schemata-b</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/conf-b</schemaLocation>
<includeSchemas>
<includeSchema>xyz.xsd</includeSchema>
</includeSchemas>
<options>
<package>my.package.b</package>
</options>
</configuration>
</execution>
</executions>
</plugin>
如果您可以更改 xsd 文件中的名称空间,那么生活会更轻松。