0

I am using SpringFramework for web server.

Sometimes I need to do asynchronous task to implement certain function.

Usually, I prefer to use

  • @Inject @Component(which is implements Runnable) in @Service.

But I am not sure is it OK or not.

So I got a question just like the title.

  • '@Inject thread bean in @Service'

OR

  • '@Inject service bean in @Component'

I want to know which way is more frequently uses.

Thanks in advance:D

Have a good Day!

fujy
  • 5,168
  • 5
  • 31
  • 50
Juneyoung Oh
  • 7,318
  • 16
  • 73
  • 121

1 Answers1

0

EDIT:

Based on edited question and commentary the answer has been changed.

@Component is generic @Service is specific

@Inject is replaced by @Autowired

You always want to use @Autowired @Service instead of other combinations.

For architectural differences you will only get information from the API documents themselves.

for further detail check this out:

What's the difference between @Component, @Repository & @Service annotations in Spring?

Community
  • 1
  • 1
Aeseir
  • 7,754
  • 10
  • 58
  • 107
  • Yeah, you are right. But my question is not what is different between '@Inject' and '@Autowired', it is about architecture perspectives. – Juneyoung Oh Jul 06 '14 at 07:13