English 中文(简体)
生成吉布克斯至String 方法
原标题:Jibx generating toString method

我目前正在使用 Jibx maven 插件来从一个定义的公式中调制 Java POJOS 代码。 代码生成精细, 但我想要的是也生成到 String 方法 。 当我从 Schema 到 类的双程旅行时, 我无法手动定义 to String 方法, 因为它在我再生成时会被覆盖 。 而我不想要创建一个仅用于 String 方法的包装类 。

是否有国旗选项或某处可以表示我想要生成“ 点火” 方法??? 我看过Jibx 在线文件,无法找到对上述问题的简单直截了当的答案 。

任何帮助都将非常感谢。

太感谢了

问题回答

user983022,
There is no automatic way to add code to a generated java clas in JiBX, but...
You have several options to solve this problem:

  1. Override your generated class and add the toString() method. (Easiest)
  2. Manually modify the generated code and then bind it with JiBX. (Breaks if the schema changes in the future)
  3. Add a maven plugin to modify the source code between the code generation and the binding step. I m sure there s a sed-like plugin that can do this... if not, it would be easy to write. (You have to find/write a plugin that can do this)

我希望这能帮上忙!

Don
JiBX Maven plugin author





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签