Home > Back-end >  What's the use of @ Component is written in the interface?
What's the use of @ Component is written in the interface?

Time:11-25

Company projects have an interface to write @ Component annotation have what use? If there is a great god knows what

CodePudding user response:

Spring annotations, is a component, refer to all types of components, contains @ Controller, @ Service, @ Repository, these annotations classes will be registered in the IOC container, as in the XML file configuration & lt; Bean id="XXX" & gt;

CodePudding user response:

This interface implementation class do you have any comments?

CodePudding user response:

refer to the second floor oh_Maxy response:
this interface implementation classes do you have any comments?

No implementation class

CodePudding user response:

reference weixin_43508665 reply: 3/f
Quote: refer to the second floor oh_Maxy response:

This interface implementation class do you have any comments?

No implementation class

That the project can start is not an error?
This interface without any local reference?

CodePudding user response:

Is the dependency injection, an annotation scanning method

CodePudding user response:

reference 1/f, thin black camel died response:
spring annotations, said is a component, refer to all types of components, contains @ Controller, @ Service, @ Repository, these annotations classes will be registered in the IOC container, as in the XML file configuration & lt; Bean id="XXX" & gt;

Didn't pay attention to see a problem, I'm sorry, on the interface using the @ component annotation is pointless, think it is very simple, the interface is not a constructor, then the bean cannot be created

CodePudding user response:

@ component annotation is a component of the spring annotations is similar to @ Service, @autowired, @ Controller annotations, discussion were carried out to distinguish the file or the class belongs to the project that piece such as Service layer, control layer. 2 will start the annotation used in project will be scanned to will manage to spring into the spring container, then can call in spring's specification

CodePudding user response:

reference 4 floor oh_Maxy response:
Quote: reference weixin_43508665 reply: 3/f

Quote: refer to the second floor oh_Maxy response:

This interface implementation class do you have any comments?

No implementation class

That the project can start is not an error?
This interface without any local reference?

A reference also call the method
To mark the @ FeignClient this annotation

CodePudding user response:

Do you have some books to see not have?
Is the meaning of the annotation will be handed over to the spring container annotation class management, there is no other special meaning

CodePudding user response:

refer to the eighth floor weixin_43508665 response:
Quote: refer to 4th floor oh_Maxy response:

Quote: refer to the third floor weixin_43508665 response:

Quote: refer to the second floor oh_Maxy response:

This interface implementation class do you have any comments?

No implementation class

That the project can start is not an error?
This interface without any local reference?

A reference also call the method
The annotation to the mark @ FeignClient

An interface implementation class, also to call its methods, not science, and should be the implementation class, play in the jars?

CodePudding user response:

refer to the eighth floor weixin_43508665 response:
Quote: refer to 4th floor oh_Maxy response:

Quote: refer to the third floor weixin_43508665 response:

Quote: refer to the second floor oh_Maxy response:

This interface implementation class do you have any comments?

No implementation class

That the project can start is not an error?
This interface without any local reference?

A reference also call the method
The annotation to the mark @ FeignClient

This is the spring annotations in the cloud

CodePudding user response:

You the mark @ FeignClient's move on to the remote invocation, the realization of his class in other project, this is inside springcloud annotations, you can look at

CodePudding user response:

To show that he is a component, spring will scan it

CodePudding user response:

Annotation is a kind of contract, such as added @ Controller class that will be considered by the Spring as a Controller, and don't have to inherit the Controller class,

CodePudding user response:

You first look at the principle of the IOC is why use this annotation

CodePudding user response:

This is equivalent to the controller class @ controller, the service class @ the annotation of the service, this is equivalent to general
  • Related