Hi im pretty new to spring boot. I have a spring boot application with controllers, services and dao(say A). Is there any way i can use this application as a dependency such a way that when i run another spring boot application(Say B) with the A as dependency. I must be able to run the controllers,Services and Dao in both A and B. Is this possible? If Possible how to do it?
You can certainly do that ! Use exec
plugin like this
For e.g. in Service A pom.xml
mention this
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
Post mvn clean install
you will see a version of your service A. Pick up that version and
Use Service A as a dependency in Service B by specifying dependency tag like below
<dependencies>
<dependency>
<groupId> com.yourAppGroup </groupId>
<artifactId> com.serviceA </artifactId>
<version> 1.0-Snapshot </version>
</dependency>
</dependencies>
I suggest to not use Controllers/services from dependency, instead only DAO. Service specific code should be in service only !