相关疑难解决方法(0)

jaxb2-maven-plugin只执行第一次执行

我正在尝试使用jaxb-maven插件使用JAXB将多个XSD转换为不同包中的POJO.我已将其设置为使用多个执行块,第一个执行块执行,然后我收到一条消息:在架构或绑定文件中未检测到任何更改

这是我的pom.xml的摘录:

...
<build>
    <pluginManagement>
        <plugin> 
            <groupId>org.codehaus.mojo</groupId> 
            <artifactId>jaxb2-maven-plugin</artifactId> 
            <version>1.5</version> 
        </plugin>
    </pluginManagement>
    <plugins>
    <!-- JAXB GENERATOR PLUGIN -->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>                    
        <execution>
            <id>Application0</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
            <packageName>za.co.mycee.application.model</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>                
        <execution>
            <id>Application1</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
            <packageName>za.co.mycee.application.model.version1</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>
        <execution>
            <id>Application2</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version2</schemaDirectory>
            <packageName>za.co.mycee.application.model.version2</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>        
        </executions>
    </plugin>
    ...
</build>
....
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误消息:

[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application) …
Run Code Online (Sandbox Code Playgroud)

java jaxb2 maven

12
推荐指数
1
解决办法
8111
查看次数

从具有类似属性名称的XSD生成JAXB类

我使用maven-jaxb2-plugin从xsd生成jaxb注释类.我有很多像这样的xsd文件:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="A3">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="loginPartner">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:string" name="login"/>
              <xs:element type="xs:string" name="password"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="A3">
    <xs:complexType>
      <xs:sequence>
        <xs:element type="xs:string" name="errorCode"/>
        <xs:element type="xs:string" name="errorDescription"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

当我运行maven插件时,它给了我一个错误:

[ERROR]解析模式时出错.位置[file:schema1.xsd {10,16}].org.xml.sax.SAXParseException:'A3'已经定义

有没有什么办法解决这一问题?实际上我有很多XSD代表来自/来自服务器的请求/响应消息.我想简化创建,验证,解析消息.也许还有另一种解决方案吗?

java xml xsd jaxb2 maven-jaxb2-plugin

4
推荐指数
1
解决办法
7006
查看次数

标签 统计

java ×2

jaxb2 ×2

maven ×1

maven-jaxb2-plugin ×1

xml ×1

xsd ×1