ozzem
ozzem

Reputation: 294

Adding Spring project to Spring Boot project as a dependency in the pom.xml

I have a Spring Project and I want to add it (as dependency) to a Spring boot project. Is it possible?

I don't really know if I say something of really impossible (I don't know spring boot).

Upvotes: 2

Views: 879

Answers (1)

Anish B.
Anish B.

Reputation: 16589

Yes, you can do it.

  1. Change <packaging> from war to jar in pom.xml of the spring project.

    <packaging>jar</packaging>

  2. Do a Maven clean and Maven install - Command : mvn clean install to produce a jar file of the spring project.

  3. Create local repository of the jar to be held in the .m2 folder.

Command to create it- mvn install:install-file -Dfile=<<path>><<name of the jar>>.jar -DgroupId=<<base package name>> -DartifactId=<<name of the jar>> -Dversion=<<version number>> -Dpackaging=jar

  1. Now, add the dependency in the pom.xml of the spring-boot project.

    `<dependency>
         <groupId><<base package name>></groupId>
         <artifactId><<name of the jar>></artifactId>
         <version><<version number>></version>
     </dependency>`
    

That's it.

Note : Download the maven and set it to the path variable of the system.

Upvotes: 3

Related Questions