C
C
click_f2016-11-06 19:20:39
Java
click_f, 2016-11-06 19:20:39

What is the difference between dependency injection by reference or by value?

The question is about the Spring Framework. You can inject dependencies, for example, into some service, by ref="" , or you can by value="". In what cases should one or the other method be used?
Correct me if I misunderstood something.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evhen, 2016-11-07
@click_f

value - for primitives, strings, ${properties} and #{Spring Expression Language}.
ref - if you need to inject the bean. The ref specifies the bean id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question