简体   繁体   中英

How to inject one POJO object to another POJO using spring annotation?

I've created a pojo class A(which is basically neither a service nor repository) and I want to inject it to another pojo class B, and this pojo class B I'll inject to a service class later. Can you tell me what annotation should I mark to class A, so that it will be treated as spring bean and it could be autowired to class B

I know one annotation @Component but I'm not sure if this would be good practice to use this annotation in spring boot.

@Component is the base annotation and it's perfectly fine to use it.

@Service is only as specialization without any behavior and @Repository is used for Data access and @Controller for web.

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