Mihir Khandekar
Mihir Khandekar

Reputation: 108

Using multiple External JARs in Spring Boot Eclipse

I have an external JAR of a Spring Boot project with package com.abc.external, and my main Spring Boot project with package com.code.main. I want to include classes (bean) from com.abc.external in com.code.main main function. I am doing it the following way.

@Configuration
@ComponentScan(basePackages = { "com.abc.external", "com.code.main" })
@EnableAutoConfiguration
@EnableJpaRepositories(basePackages = { "com.abc.external", "com.code.main" })
@EntityScan(basePackages = { "com.abc.external", "com.code.main" })
public class App {
    //code
}

If I import the com.abc.external project into Eclipse, then the external base package is getting identified. However, if I just have the dependency in POM.xml, it is not getting identified. The JAR is present in the lib folder.

What should I do to use an external JAR package along with my original one in the Spring Boot project?

Upvotes: 1

Views: 939

Answers (1)

Joe W
Joe W

Reputation: 2891

You will need to install the jar from the lib folder into your local maven repository in order for it to be available to maven and subsequently eclipse.

https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

In your case the command would be something like:

mvn install:install-file -Dfile=lib/<jar-name> -DgroupId=com.abc -DartifactId=external -Dversion=<your-version> -Dpackaging=jar

Then update your Eclipse classpath with mvn eclipse:eclipse Alternatively you could deploy your com.abc.external jar to a maven repository and reference it from there.

Upvotes: 1

Related Questions