How to convert springboot project to its equivalent maven multi-module project

167 Views Asked by At

So I have this spring-boot project that contains the web services of an application. Now I want to add a new module to my application that is not related to the web services. To do so in Java I found that you can create a multi-module project.

What I have been trying for the past hours is to convert the whole project to a single submodule of a bigger project. I kind of achieved it, but some of the plugins change and my code gives error about a circular dependency, so this is not a valid solution. My code should be working as it was before I changed the project structure.

I think that the problem comes from the fact that to convert this project into a multi-module project I needed to delete the POM parent of my application (spring-boot-starter), because the new parent is going to be the global project.

So, in this documentation, there is explained what do you need to do to not use the parent POM.

They tell you that to override libraries and achieve the same result you need to put the dependencies in the dependencyManagement section. This is not working for me. When doing so, dependencies are not used to compile and they do disappear from maven, resulting in not finding libraries in my code.

Another thing that changes a lot (and maybe is the source of my error) is that almost all maven plugins change versions when deleting the parent. Do I need to set all the plugins and their versions manually now that they are not managed by the spring-boot parent POM? Would it make sense to think that maybe because of changing the versions of the plugins now there is a circular reference in my code?

I would like to see an exhaustive step-by-step guide to convert a spring boot project into a maven multi-module project (where one of the submodules is the original spring-boot project converted into module). There are a lot of instructions and guides on the Internet but most of the time they do not explain why are they doing what they doing and also they are not exhaustive. They usually use very small example projects and it seems to me that they do not take into account all the aspects that need to be taken care of when migrating a large project. I would like to see how can I move the project and also conserving all the aspects, plugins and dependencies of it, so it is basically a clone of the original project but in a module and works exactly the same.

Please, notice that there may be similar questions as the one I am posting, but the answers do not satisfy me at all and / or are not working for me.

You can also answer me by proposing any possible workaround. For example, having a solution that implies to not delete the spring-boot parent POM would be the cleanest.

Thank you so much for the help. It is very valuable to me.

0

There are 0 best solutions below