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
精彩评论