With java annotation simulated landing, implementation bean tag of simulation spring

1. simply recognize notes

  • java in comments posted on the class like a label on the property or on the label and the text is to use annotation properties of the annotation defined. Property defines the required annotations added after the name () to do so because the property can be from another class, obtaining the target annotation, that calls the method to get the value of the annotation tag;
  • Case 1:
    Here Insert Picture Description
    Here Insert Picture Description
    imitate achieve a DAO and a class Service class:
    Here Insert Picture Description
    Here Insert Picture Description
    two test methods, notes on a class test, a test annotation on the property:
    Here Insert Picture Description
    Here Insert Picture Description
    the property-related note:
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description

2. imitate beanFactory realization of spring

Here Insert Picture Description
Here Insert Picture Description

  • Case 2: Log in case
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
    problems that may arise, can not initialize Component annotation when to inject property value Autowired because of the following problems occur
    Here Insert Picture Description

3. spring in the bean implementation labels

Here Insert Picture Description
Corresponding xml file:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Published 103 original articles · won praise 91 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_42512488/article/details/100532924