Additional Exercises for Mastering Spring Framework 4 Essentials

These are additional exercises you can try out once after learning and practicing all the previous exercises in this section. There will be also hints to make things easier.

  1. Provide examples for autowire for type and autowire by construtcor following the note

  2. Rewrite the following programming using annotations and java configuration:

  3. Give examples for the usage of following annotations following the same example program in this section: @Autowired, @Resource, @Inject.

    • What will happen if I change a @Autowired annotation in the examples within the section with @Resource or @Inject?

  4. Write a program that will fail without @Qualifier, but will pass once using @Qualifier.

  5. Write a program that will fail without @Primary, but will pass once using @Primary.

  6. Rewrite the following program using xml configuration:

    • Useful bean attributes:

      • factory-method alone can be used to specify a getInstance method of the class to create the instance. 

      • factory-bean and factory-method to specify a different factory class.

  7. Print the bean definition count and the bean definition names for the following programs from within the main program and compare:

  8. Rewrite this program using XML configuration:


  • You can submit your solutions for review and better ones may get added to the current section of notes. You will receive 1000 points for every accepted solution that feature on this site. If solutions are similar, winner will be decided on a first come basis. Please check first if the solution is already completed by anyone. Comment on this page once you send us the solution. You may also check with us upfront using the contact page before wotking on any solution to make sure noone else is working in parallel.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within!!!