json - How to use model classes in both Website and Web service? -
i building demo application using spring web mvc , hibernate , jersey rest services.for created 2 dynamic web projects - 1 site, 1 service. model classes defined in website project , ones passed views.
now, hibernate code in web service , , requires these same model classes. , have created exact same model classes in web service project ( duplicate code ). correct ?
the data exchange through json (using gson library), each time there request /response, recreating objects json.
is how should done . works , wondering if there way use same classes in model / web service in ?
should use third project contains model classes , reference same 1 in both projects? sufficient ?
why not having 1 project backend , frontend modules.
the backend contains services, repositories, transaction manager , data sources.
the fronted can have both web app , web services in single war. can use 2 different root paths mvc , ws:
web-context/web-app/
web-context/rest/
Comments
Post a Comment