Can I convert existing Spring project to Cuba

Is it possible to convert an existing spring or spring boot application to Cuba?

if yes, is there any documentation?

Thanks

There is no wizard tool to do that for you automatically.
Cuba lays on top of the Spring framework, but the next version of CUBA is called Jmix and uses Spring Boot, so you may want to look at that https://www.jmix.io/

However, the same applies to both CUBA and Jmix

  • in order for your Java code to "work under CUBA " it needs to import CUBA dependencies and contain necessary annotations, and follow the CUBA project structure
  • for database user interfaces IMO adapting is bad, if you have a database CUBA will read it and generate it much faster and better than you would need to adapt anything, so then just copy-paste your custom code/business logic into beans or subscribe to graphical control events like button clicks, form showing, etc.
2 Likes

Hi,

Yes, it is possible (in theory), but requires some manual work. Basically, you’ll have to reimplement your data access layer with CUBA/Jmix as well as security.

So, we’d advise creating an empty CUBA/Jmix project and then copy the existing code layer-by-layer, starting from entities.

If you have Spring Boot project, it would be reasonable to use Jmix.

The steps you’ll most probably need to follow (but it really depends on your app architecture, code complexity, application size, etc.)

  1. Create empty entities with proper names and then copy your existing entities’ internals into those “empty” entities. Mind “soft delete” and “versioning” features.
  2. Review your data access layer and reimplement it using DataManager or experimental Jmix Spring Data repositories.
  3. Services and MVC/REST controllers can be copied “as is” in most cases, just replace data access code.
  4. Review your security model and create proper roles for data access.

It is a very high-level plan, every application is different, so it is hard to say what exactly should be done in your particular case.

BTW Jmix 1.0 is out, so you can try the migration using this version.

1 Like