1

I am new to Spring and working on a project which is consisting of Spring in it . It has got this piece of code inside the xml file

   <bean id="quotClient" class="com..at.client.QuoteClient" scope="singleton" />
   <bean id="streamClient" class="com.at.client.StreamClient" scope="singleton" />

And inside the java class it has got this piece of code

@Autowired
@Qualifier("streamClient")
private StreamClient sclient;



@Autowired
@Qualifier("quotClient")
private QuoteClient quotesClient;


public void setQuotesClient(QuoteClient quotesClient) {
    this.quotesClient = quotesClient;
}

Please let me know why there is no method by name set for the StreamClient class , but which has got corresponding set method for QuoteClient .

anubhava
  • 761,203
  • 64
  • 569
  • 643

2 Answers2

0

Since you're using annotation driven Autowiring of the beans you don't need any setters for injunction (these are set by using reflection). Even setQuotesClient isn't needed by Spring DI framework to inject those 2 bean instances.

PS: From spring version 3.0, you can start using @Inject instead of @Autowired.

Check: How does Spring @Autowired work

Community
  • 1
  • 1
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

i think that setter method wrote by mistake. remove that setter and test the application. it should work.

Chamly Idunil
  • 1,848
  • 1
  • 18
  • 33