Environment :
Spring 4
Hibernate 4
MySQL
Spring MVC REST
Issue :
I am writing a simple REST based application for CRUD operations.
The architecture/components is below :
I have below design issues :
1. In Spring Application , the best practice is to have two separate contexts -
i) applicationContext : initialised through ContextLoaderListener (for servives abd daoLayerClasses)
ii) webApplicationContext : initialised through Dispather servlet (for Controllers/view Resolvers)
2. However I haven't seen any sample Spring REST based application using BOTH THE CONTEXTS above. Only Dispatcher servlet appraoch is used.
3. So , will creating two separate contexts for REST based application as shown in above architecture be an overkill and unnecessary ?
Or It is better to create two contexts separating SPRING REST layer in WebApplicationContext (@RestController
) and ApplicationContext containing
(@Services
,@Repository
)