Java – how do I enable @ required?
How to enable the @ required annotation in Java (spring 3.1)? Not in XML, but in Java What other comment can I enable this? Under @ feature (in @ futureconfiguration or @ bean (in @ configuration)?
Edit:
@Feature public MvcAnnotationDriven annotationDriven(ConversionService conversionService) { return new MvcAnnotationDriven().conversionService(conversionService) .argumentResolvers(new CustomArgumentResolver()); }
Does this support all comments?
Solution
@Anubhava's answer is valid, but he cites the spring 2.0 manual, which is five years old
In the XML configuration, spring 3 X has a more elegant method: < context: annotation config / > This also enables a host of other features you might want, while the required annotation bean post processor only enables some features
See spring 3 x manual.
If you are using @ bean style configuration, you should have enabled annotations such as @ required, because this is how @ bean works However, this may be a mistake - spring 3.1 is still in early testing, and most of it may be broken
Unless you really know what you're doing, I strongly recommend you stick to 3.0 x.