Java 如何管理多模式maven-jaxb2-plugin
这是我第一次使用maven-jaxb2-plugin,这个麻烦让我发疯。 我有两个.xsd模式,从中可以得到两个java包 这是我的maven-jaxb2-plugin配置Java 如何管理多模式maven-jaxb2-plugin,java,maven,maven-jaxb2-plugin,Java,Maven,Maven Jaxb2 Plugin,这是我第一次使用maven-jaxb2-plugin,这个麻烦让我发疯。 我有两个.xsd模式,从中可以得到两个java包 这是我的maven-jaxb2-plugin配置 <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>schema1-generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<systemPropertyVariables>
<user.language>en</user.language>
<user.region>GB</user.region>
</systemPropertyVariables>
<schemaDirectory>src/main/resources/myPath/schema</schemaDirectory>
<schemaIncludes>
<include>schema1.xsd</include>
</schemaIncludes>
<generatePackage>it.mycompany.jaxb1</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/xjc1</generateDirectory>
<readOnly>true</readOnly>
</configuration>
</execution>
<execution>
<id>schema2-generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<systemPropertyVariables>
<user.language>en</user.language>
<user.region>GB</user.region>
</systemPropertyVariables>
<schemaDirectory>src/main/resources/myPath/schema</schemaDirectory>
<schemaIncludes>
<include>schema2.xsd</include>
</schemaIncludes>
<generatePackage>it.mycompany.jaxb2</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/xjc12</generateDirectory>
<readOnly>true</readOnly>
</configuration>
</execution>
</executions>
</plugin>
现在,我正试图以这种方式解开它们:
String schemaChhosed = "pathSchemaChoosed"
String packageNameChoosed = "packageNameChoosed"
JAXBContext jc = null;
Unmarshaller unmarshaller =null;
jc = JAXBContext.newInstance("packageNameChoosed");
unmarshaller=jc.createUnmarshaller();
Schema schema1 = sf.newSchema(new File("pathSchemaChoosed"));
Dev dev=(EdiL)unmarshaller.unmarshal(new File("myFile.xml"));
问题是我无法理解什么
发展
必须实例化
it.mycompoany.jaxb1 Dev dev=(EdiL)unmarshaller.unmarshal(new File("myFile.xml"));
it.mycompoany.jaxb2 Dev dev=(EdiL)unmarshaller.unmarshal(new File("myFile.xml"));
我想用dinamic的方式处理这个问题,你能给我一些建议吗 是否要从一个架构中生成两个包?这是您的配置所说的。可能重复
it.mycompoany.jaxb1 Dev dev=(EdiL)unmarshaller.unmarshal(new File("myFile.xml"));
it.mycompoany.jaxb2 Dev dev=(EdiL)unmarshaller.unmarshal(new File("myFile.xml"));