Field-based injection

With the @Autowired annotation, you can apply it directly to a field. In this way, you don't need to declare a setter method for it, as in the following:

@Autowired
private MessageRepository repository;

Other annotations: Besides the built-in annotations, @Required and @Autowired, Spring also supports the @javax.annotation.Resource annotation specified in JSR-250 and the @javax.inject.Inject annotation from JSR-330.

Java Specification Request (JSR): JSR 250 is for common annotations for the JavaTM platform. JSR 330 is about dependency injection for Java. You can find more details at: https://jcp.org/en/jsr/detail?id=250 and https://jcp.org/en/jsr/detail?id=330
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.178.9