Home > database >  How to use spring boot application as dependency in existing springboot application
How to use spring boot application as dependency in existing springboot application

Time:10-25

I'm new to Spring-boot and I'm stuck on one of the problem.

Problem Statement: We have an existing product which is written on top of java spring(maven, war package) and I cannot touch the source code of this application. So to extend the feature of existing application(say adding additional api's), I want to write a spring-boot application(maven,jar) and add as dependency in existing application's pom.xml.

I want to know is it possible? if yes, please share the concept.

CodePudding user response:

If you have a built jar and wish import this jar into new spring-boot project try this

https://stackoverflow.com/a/68011833/7505687

Don't forget to tell to new spring-boot project scan beans or configuration from imported jar

https://stackoverflow.com/a/68011833/7505687

CodePudding user response:

You can write a separate application with the functionality you need and do a clean install. The next step is to call your new service as a dependency in the base application. To do this, do the following

configure this data with a new service (which you will call from the base one) this should be written in the pom.xml of the new service at the top

    <modelVersion>4.0.0</modelVersion>
    <artifactId> yourNewService </artifactId>
    <groupId> your.group.id </groupId>
    <version> 0.0.1-SNAPSHOT </version>
    <packaging> jar </packaging>

then trying to load your functionality from the base service as a dependency

  <dependency>
            <groupId>your.group.id</groupId>
            <artifactId>yourNewService</artifactId>
            <version>${yourNewService.version}</version>
        </dependency>
  • Related