0
私のスキーマのいくつかをいくつかコントロールしていますので、私の質問はこれと似たものと少し異なります。私は3つのスキーマ、c.xsdインポートb.xsd、b.xsdインポートa.xsdを持っています。 3つすべてが異なる名前空間を持っています。2つのクラスは同じXMLタイプの名前を持っていますmaven jaxbプラグイン、Spring
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns="ANamespace" targetNamespace="ANamespace" version="1.0" jaxb:extensionBindingPrefixes="xjc" jaxb:version="1.0">
<xs:complexType name="ClassA">
<xs:sequence>
<xs:element name="classAFieldName" type="xs:string" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns="BNamespace" targetNamespace="BNamespace" version="1.0" jaxb:extensionBindingPrefixes="xjc" jaxb:version="1.0">
<xs:import namespace="ANamespace" schemaLocation="a.xsd"/>
<xs:complexType name="ClassB">
<xs:sequence>
<xs:element name="classBFieldName" type="xs:string" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns="CNamespace" targetNamespace="CNamespace" version="1.0" jaxb:extensionBindingPrefixes="xjc" jaxb:version="1.0">
<xs:import namespace="BNamespace" schemaLocation="b.xsd"/>
<xs:complexType name="ClassC">
<xs:sequence>
<xs:element name="classCFieldName" type="xs:string" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
クラスAが一度org.testing.commonで、一度org.testing.cで、二回生成され、それらの両方どちらも同じ名前空間@XmlType(name = "ClassA"、namespace = "ANamespace")を持っていますが、Springはどちらを使うかを知りません。クラスAが2回生成される必要がありますか?
ここ私の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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wfs.fi.stp</groupId>
<artifactId>testing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>testing</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<versionRange>[0.13.1,)</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<configurator>
<id>org.eclipselabs.m2e.jaxb2.connector.Jaxb2JavaProjectConfigurator</id>
</configurator>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<id>A</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>a.xsd</include>
</schemaIncludes>
<bindingIncludes>
<include>a.xjb</include>
</bindingIncludes>
<generatePackage>org.testing.common</generatePackage>
<generateDirectory>${project.build.directory}/common_generated</generateDirectory>
<episode>true</episode>
<episodeFile>${project.build.directory}/common.episode</episodeFile>
<extension>true</extension>
<verbose>true</verbose>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>all</value>
</property>
<property>
<name>javax.xml.accessExternalDTD</name>
<value>all</value>
</property>
</properties>
<args>
<arg>-npa</arg>
</args>
<disableXmlSecurity>true</disableXmlSecurity>
<accessExternalSchema>all</accessExternalSchema>
<accessExternalDTD>all</accessExternalDTD>
</configuration>
</execution>
<execution>
<id>B</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>b.xsd</include>
</schemaIncludes>
<generatePackage>org.testing.b</generatePackage>
<generateDirectory>${project.build.directory}/b_generated</generateDirectory>
<bindingIncludes>
<include>b.xjb</include>
</bindingIncludes>
<episode>true</episode>
<args>
<arg>-b</arg>
<arg>${project.build.directory}/common.episode</arg>
<arg>-npa</arg>
</args>
<episodeFile>${project.build.directory}/b.episode</episodeFile>
<extension>true</extension>
<verbose>true</verbose>
<disableXmlSecurity>true</disableXmlSecurity>
<accessExternalSchema>all</accessExternalSchema>
<accessExternalDTD>all</accessExternalDTD>
</configuration>
</execution>
<execution>
<id>C</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>c.xsd</include>
</schemaIncludes>
<generatePackage>org.testing.c</generatePackage>
<generateDirectory>${project.build.directory}/c_generated</generateDirectory>
<bindingIncludes>
<include>c.xjb</include>
</bindingIncludes>
<args>
<arg>-b</arg>
<arg>${project.build.directory}/b.episode</arg>
<arg>-npa</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.4</version>
</plugin>
</plugins>
<extension>true</extension>
<verbose>true</verbose>
<disableXmlSecurity>true</disableXmlSecurity>
<accessExternalSchema>all</accessExternalSchema>
<accessExternalDTD>all</accessExternalDTD>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
それは本当に何も変わらなかった。 ClassA.javaは2回生成されます。 org.testing.commonと@XmlTypeで生成された@XmlType(name = "ClassA"、namespace = "ANamespace"、propOrder = { "classAFieldName" })は次のとおりです。この問題は、両方ともANamespaceにあるということです。パッケージは問題ないと思われます。また、毎回 – noobjob
_A_と_B_目標の実行と ''設定を削除しましたか?使用しているプラグインになじみがありませんしかし、ベストプラクティスのページは、[パッケージの生成](https://github.com/highsource/maven-jaxb2-plugin/wiki/Configure-Target-Packages-in-Binding-Files)を使用することに対して警告します。 –
teppic
さて、私はそれを試みた(AとBを取り除くe xecutionsと config)を作成し、すべての名前空間に対して1つのバインディングファイルを作成しました。興味深いのは、すべてがまだ2回生成されていますが、ClassA/B/Cは@XmlTypeアノテーションにJavaパッケージ名anamespace/bnamespace/cnamespaceとNO namespace属性を持っています。これらのファイルを無視して、私はSpringを混乱させてはいけないと思います。ご協力いただきありがとうございます! –
noobjob