开发者

Spring Bean Configuration: How to mark beans as mandatory/optional?

I am making heavy use of Springs XML Configuration for Java Beans. Is there a best practice to mark a property of a bean as optional or required? I am currently initializing the optional beans in the default constructor. If one of the required properties it not set in most cases a NullPointerException will be thrown, but that doesn't really seem to be a good solution.

开发者_如何学编程Sincereley, Heinrich


There is the @Required annotation that you can use on mandatory fields.


You can set bean lazy which are not frequently required , they will be initilized only when they actually needed.

Doc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜