OJVM
OJVM

Reputation: 1481

Package scanning Spring 3 context:component-scan

in the <context:component-scan base-package= is there any diference in doing com.mycompany.proyect.dao or com.mycompany. I have this doubt because in both ways works. I have a project A that access some data, this project is packed as a jar, then the project B imports project A. Both have different package structure like com.mycompany.proyectA.dao and com.mycompany.proyectB.dao. So, to make the component scanning work. i declared the context:component-scan as follows com.mycompany. I must to say that this declaration is working, but in every example in spring (or other places) always use com.mycompany.dao. Are there some issues working in this way?

Thank you.

Upvotes: 0

Views: 297

Answers (1)

Arun Padmanabhan
Arun Padmanabhan

Reputation: 119

As far as I can tell, there seems to some conflict between DAO methods in com.mycompany.proyectA.dao and com.mycompany.proyectB.dao

The solution is to split into 2 context:component-scan one for projectADao and one for projectBDao.

Further more you can split the context:component-scan in 2 xml files like daoA.xml and daoB.xml and then have a context:component-scan in each , ex: context:component-scan as com.mycompany.proyectA.dao and context:component-scan as com.mycompany.proyectB.dao respectively.

Upvotes: 1

Related Questions