是否可以在 Spring 中扩展 pojo 类?
我有一个 pojo,其中包含一组私有变量及其 setter 和 getter。这个 pojo 在我的应用程序中广泛使用。现在,我必须支持一个场景,其中有多个 pojo,并且每个 pojo 都是我拥有的初始 pojo 的超集。我是否可以扩展我原来的pojo,这样我就不需要改变我现有的业务逻辑。 我是春天的新手,我不知道这是否可能。 Pojo B 应该包含 pojo A 中的所有内容以及更多内容。 在代码中,我将通过 pojo A 创建 pojo B 对象。 基本上,有些类似于继承的东西,但是带有pojos。
I have a pojo which contains a set of private variables and their setters and getters. This pojo is used extensively across my application. Now, I have to support a scenario where there are multiple pojos and each pojo is a superset of the initial pojo I have. Is it possible that I can extend my original pojo so that I need not change my existing business logic.
I am new to spring and I dont know if this is possible.
Pojo B should contain everything in pojo A and few more things.
Inside the code I will create pojo B objects through pojo A.
Basically, some thing similar to inheritance, but with pojos.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,您可以聚合或继承。
继承:
聚合
Typically, you would either aggregate or inherit.
Inherit:
Aggregate