I have created two spring boot applications - foo
and bar
. I then created a jar file for bar
with the command mvn clean package
, which resulted in the bar-0.0.1-SNAPSHOT.jar
file. Using mvn install:install-file -Dfile=target/bar-0.0.1-SNAPSHOT.jar -DpomFile=pom.xml
as mentioned in this post, I installed this jar to my local .m2 repository.
Then in the pom.xml of foo
, I added the following dependency:
<dependency>
<groupId>com.foobarcompany</groupId>
<artifactId>bar</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Now, when I run the foo
app from STS, it runs correctly, but if I try to run it form terminal with mvn spring-boot:run
or try to package foo
with mvn clean package
, I get the following error:
package com.foobarcompany.bar.service does not exist
which is referring to a service present in the bar
app that I'm calling from the foo
app.
As far as I understand, the dependency is not correctly added and the reason it works from STS is because both applications are under the same workspace.
I have even tried adding a local maven repository as mentioned in this answer but even that doesn't seem to work. Or maybe I'm doing it wrong.
Could anyone please tell me what the correct way to add a local jar to another application is?