I am studying for the Spring Core certification and I have some doubt to the following question finded on this old exam mock (this is related to the Spring v3 and now there is the v4 but I think that many topics are the same).
Given the following Spring configuration file, what is the correct answer:
<bean class ="com.spring.service.MyServiceImpl">
<property name="repository" ref="jpaDao" />
</bean>
<bean class="com.spring.repository.JpaDao"/>
The first declared bean MyServiceImpl is missing an id must be named myService.
The second declared bean JpaDao is missing an id must be named jpaDao
Answers 1 and 2 are both rights
Answers 1 and 2 are both wrong
My original idea is that both the answer are right because both the bean have no id specified so if it is true that the second bean need an id=jpaDao because the first one use it as reference I thought that also the first been need an id. Otherwise how can it be called? (also in the code from the factory?)
But reading the anser finded into the mock it say that the right answer is the second.
So what it means? that in Spring is not mandatary specify an id for each bean? If it is true how can I referer or instantiate the first bean using the factory if it have no id? What am I missing?
Tnx
Aucun commentaire:
Enregistrer un commentaire