Feb 27th, 2012, 10:22 AM
Annotations vs XML Config
I have a friend that is upset with annotations because he doesn't have a full view into all the beans, controllers, etc in one view. The annotations are littered throughout his project and can't figure out where everything is. I personally like annotations but everyone has their own style. I suggested to him that it would be easy with annotations to have them scanned to provide a report of how everything is wired together.
Are there any tools that help give better visibility into spring projects by scanning for all the annotations and provide a report to see how everything is wired together?
Feb 27th, 2012, 11:35 PM
We use Springsource Tool Suite and spring explorer gives us the view of all beans. I am not sure whether you need this info for reporting or developer help. If it is for latter, I would definitely look at STS.
Feb 28th, 2012, 05:33 AM
Annotations vs XML Config and organized all matters in sequence so we will remind all perspectives
of Oder and get a broad vision in any stage.
Personal Trainer Overland Park
Last edited by Raul John; Mar 2nd, 2012 at 11:40 PM.
Feb 28th, 2012, 06:16 AM
Since Java adopted annotations, Iíve heard a lot of discussion around whether to prefer annotations over external configuration files (often XML) and vice versa.
I think the decision boils down to two criteria:
1) Can annotations simplify the metadata?
2) Can changes to the metadata break behavior in your application?
If annotations do not reduce the amount of metadata that you have to provide (in most cases they do), then you shouldnít use annotation.
I think the more important thing to considered is whether a configuration change could break behavior or not. If not, then you can feel comfortable applying the change while the system is running in production. External config files are the best place for the metadata in this case because you donít want to have to recompile your code to make the change.
Last edited by hasselcloud; Mar 5th, 2012 at 01:53 PM.
Mar 28th, 2012, 04:47 AM
if you are going for configuration then it is better to follow some best practices to ensure better management of config files. http://www.deepakgaikwad.net/index.p...practices.html
Mar 28th, 2012, 05:48 AM
Annotation or XML is a big discussion which could go on and on because everyone has their own reason to why they prefer one over the other.
As far as seeing a report is concerned on the various bean being used in an application, STS provides certain ways/views by which to see all the beans which are annotated. There are views such as "Beans Cross Reference", "@RequestMappings", which gives beans using annotations and methods in which @RequestMapping annotation is used.
Jan 19th, 2013, 04:05 AM
Our company Lexaden has developed a number of products with Spring 3.1, JPA 2.0, Vaadin and Lexaden Web Flow - is a MVC framework and full web flow implementation for Vaadin component model.
And I would like to sum up pros and cons of java annotation and xml configurations from our experience:
- When it comes to JPA configuration since it is done once and usually are not changed quite often we stick to annotation configuration. You may have a concern regarding possibility to see a bigger picture of configuration - in this case we use MSQLWorkbench diagrams.
- Xml configuration is very good to get a bigger picture of application but it maybe cumbersome to find some errors until runtime. In this case Spring @Configuration annotation sounds as a better choice since it let us see a bigger picture as well and also allows to validate configuration on compile time.
- As for Spring configuration we combine both approaches: use @Configuration annotation with Services and Query interfaces and xml configuration for dataSource and spring configuration stuff like context:component-scan base-package="com.lexaden.platform"
- But xml configuration bits java annotations when it comes to flow configuration since it is extremely important to see a bigger picture of the whole business process. And it sounds cumbersome to have it implemented with annotations approach.
As showcase you can try out Lexaden Administration (login/password - demo/demo)