Home > other >  How do I divide my code into two applications?
How do I divide my code into two applications?

Time:01-08

I have a few java classes, holding my application's logic. Now I want to create two applications, one will be a SpringBoot web application and another one will be a desktop application. Both of them will use logic, that I already wrote. I see only one way to do it: compiling logic classes into a .jar file and then putting it as a library into two Idea projects. But if I update any of this code, I will have to recompile it into jar and then replace an old jar with a new one in both projects.

  1. Is there another, more simple way two divide my code into two projects?
  2. What should I do with Git/GitHub?

P.S. My project is in java, I use Intellij IDEA, GitHub.

CodePudding user response:

Multi-module project

As commented, you need a multi-module project. The content for each module is compiled separately, producing separate JAR files.

IntelliJ supports multi-module projects.

I recommend using a Java build management tool to assist. Apache Maven is one such tool that supports multiple modules.


The word “module” used here in this context should not be confused for the Java Platform Module System. You may or may not choose to use Java modules in your project modules’ code.

CodePudding user response:

I suggest rest web service interface to export the logic data..

SpringBoot web application can consume the rest services
and the other a desktop application can consume the rest services

ONE REST SERVICE LAYER
--------------------------------------
 |                 |
Desktop app,     SpringBoot web application

this way to don't duplicate your code and bugs twice.

  •  Tags:  
  • Related