简体   繁体   中英

Do we have to use annotations in Spring?

I was trying to get a job for a software company that uses Spring.

Must I use annotations or could I write via xml?

Do certain companies prefer one over the other or are both generally applicable?

You can use in Spring XML configuration as some companies still uses, but it's less recommended

lose out on is the opportunity to have more succinct and clearer configuration.

It actually depends on the configuration style the project / company is following. But nowadays most people prefer java annotations based configuration over xml one. Also explicit wiring is least preferred, because when your project codebase grows, its difficult and tedious task to do explicit wiring. So many people are using java annotations based configuration with autowiring enabled. And beans are created using component scanning, except beans where you need some custom configuration eg email config, database config are defined using @Bean annotation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM