强制jaxb2-maven-plugin生成setter或构造函数

时间:2017-09-02 12:07:52

标签: java xml maven jaxb xjc

我有以下构建配置。它工作正常,但问题是生成带有所有args的构造函数或生成列表的setter。

echo "<table border='6'>";
    while($row = mysqli_fetch_assoc($query)) {
        echo "<tr><th>Application Type</th><td>{$row['applicationtype']}</td></tr>";
        echo "<tr><th>First Name</th><td>{$row['firstname']}</td></tr>";
        echo "<tr><th>Surname</th><td>{$row['lastname']}</td></tr>";
        echo "<tr><th>Title</th><td>{$row['title1']}</td></tr>";
        echo "<tr><th>Date of Birth</th><td>{$row['dob']}</td></tr>";
        echo "<tr><th>Gender</th><td>{$row['gender']}</td></tr>";
        echo "<tr><th>Nationality</th><td>{$row['nationality']}</td></tr>";
        echo "<tr><th>Country of Birth</th><td>{$row['countryofbirth']}</td></tr>";
        echo "<tr><th>Applicant's Location</th><td>{$row['applicantlocation']}</td></tr>";
        echo "<tr><th>Alias</th><td>{$row['alias']}</td></tr>";
        echo "<tr><th>Criminal</th><td>{$row['criminal']}</td></tr>";
        echo "<tr><th>Country of Passport</th><td>{$row['countryofpassport']}</td></tr>";
        echo "<tr><th>Passport Number</th><td>{$row['passportnumber']}</td></tr>";
        echo "<tr><th>Passport Issue Date</th><td>{$row['pid']}</td></tr>";
        echo "<tr><th>Passport Expiry Date</th><td>{$row['ped']}</td></tr>";
        echo "<tr><th>Address</th><td>{$row['address']}</td></tr>";
        echo "<tr><th>City</th><td>{$row['city']}</td></tr>";
        echo "<tr><th>State</th><td>{$row['state']}</td></tr>";
        echo "<tr><th>Postal Code</th><td>{$row['postalcode']}</td></tr>";
        echo "<tr><th>Country</th><td>{$row['country']}</td></tr>";
        echo "<tr><th>Email Address</th><td>{$row['email']}</td></tr>";
        echo "<tr><th>Home Number</th><td>{$row['homephone']}</td></tr>";
        echo "<tr><th>Business Number</th><td>{$row['businessphone']}</td></tr>";
        echo "<tr><th>Mobile</th><td>{$row['mobile']}</td></tr>";
    }
echo "</table>";

您能告诉我如何强制@Throws fun copyDataBase() { var myInput = context.getAssets().open(DB_NAME) var outFileName = DB_PATH + DB_NAME var fileOut: OutputStream = FileOutputStream(outFileName) val buffer: ByteArray = ByteArray(1024) var length: Int? = 0 while (true) { length = myInput.read(buffer) if (length <= 0) break fileOut.write(buffer, 0, length) } fileOut.flush() fileOut.close() myInput.close() throw IOException() } 为列表或args构造函数生成setter吗?

2 个答案:

答案 0 :(得分:0)

这件事对我有用

<configuration>
    <args>
        <arg>-Xvalue-constructor</arg>
    </args>
    <plugins>
        <plugin>
           <groupId>org.jvnet.jaxb2_commons</groupId>
           <artifactId>jaxb2-value-constructor</artifactId>
           <version>3.0</version>
        </plugin>
        <plugin>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics</artifactId>
            <version>0.11.1</version>
        </plugin>
    </plugins>
</configuration>

如果您发现此问题,请与我们联系。

答案 1 :(得分:0)

为了为集合生成 setter,我向 org.andromda.thirdparty.jaxb2_commons 添加了依赖项,但它仅适用于新版本的 jaxb2-maven-plugin .我尝试使用 2.5.0 并且它有效,使用版本 2.3.1 不起作用。 举个例子:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>2.5.0</version>
    <dependencies>
      <dependency>
         <groupId>org.andromda.thirdparty.jaxb2_commons</groupId>
         <artifactId>collection-setter-injector</artifactId>
         <version>1.0</version>
      </dependency>
   </dependencies>
   <executions>
      <execution>
             ......
       </execution>
    </executions>
    <configuration>
       <sources>
             ......
       </sources>
       <arguments>-Xcollection-setter-injector</arguments>
       <clearOutputDir>false</clearOutputDir>
       <extension>true</extension>
    </configuration>
</plugin>