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:

  1. web-context/web-app/

  2. web-context/rest/


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -