0

Does Spring supports Interface Injection completely?

From “Martin Fowler” Blog it was mentioned that a component that depends on a bean needs to implemented as an Interface that injects Bean.

When we consider this scenario it will be possible BeanNameAware, XXXAware Interfaces that injects appropriate bean object.

Is it possible to inject userdefinedd Beans using Interface Injection other than spring supplied classes.

I am confused with all the above.

1 Answer 1

1

It is correct and canonical concept.

You rely on contract (interfaces) and inject them, but container takes care of their implementations:

public interface MyService {} public class MyServiceImpl implements MyService {} <bean id="myService" class="com.my.proj.MyServiceImpl"/> public class MyController { @Autowired private MyService service; } 

Don't mix contaier components and its API (*Aware) and user-defined application components.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.