Can DTOs be spring managed beans? [closed]

不羁岁月 提交于 2019-12-08 08:30:05

问题


I am using spring 3.0.

I have few DTOs. Can I declare them as spring beans? If so what should be the bean scope?


回答1:


Usually, DTOs instantiation is not managed by spring (for instance Hibernate often instantiates DTOs).

Spring does have a prototype scope where a new object is created each time you lookup the object from the ApplicationContext. This scope is useful when you want to define default values in spring config.

See the documentation on prototype scope, here.



来源:https://stackoverflow.com/questions/21833110/can-dtos-be-spring-managed-beans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!