Grails: One Database and Multiple Applications

I have a Grails GORM based application. One web service and one website run on different ports and share a common database and tables.
What I did was create a domain class for both applications that have the same fields and domain class name. For example, a Registration table having username and password fields.One can register through a web service as well as from a website.
My current apps are working fine ... but is this an acceptable solution ..?



source to share

2 answers

You may run into race / block conditions, but I've seen this many times. My only suggestion is that you don't support separate domain classes. Put the generic domain classes in a plugin and install said plugin in both apps.

Another common approach I've seen that mimics your approach is to deploy an application facing client separate from admin / cms. Both talk to the same database, they just run on different tomcat instances.



You can create a standalone Gradle application that uses a GORM dependency that only contains the generic domain classes. Create these classes (POJO) in src / main / groovy / bla / xyz, annotate them


This will make GORM identify your POJO as a domain class.

Build this application, publish it, and use it as your dependency in another Grails application.

Before you do your best try this with one POJO class. Publish it to your local m2 repository and use it as a dependency in your Grails application, check it out.

Hope this helps



All Articles