1

I'm working on building a new microservice where I have to use a 3rd party client library to solve geolocation. I have added the dependency of that service in my pom file

<groupId>abc.xyz.abc.geo</groupId>
           <artifactId>MyGeoLocation</artifactId>
           <version>1.5.0</version>
       </dependency>

but how do I inject the dependency of this service in my new service/ application?

Jorn
  • 20,612
  • 18
  • 79
  • 126
mia
  • 73
  • 10
  • What does the actual 3rd party class look like? Is it set up for Dependency Injection at all? Maven dependencies are not dependencies in the DI sense. – Ray Apr 16 '20 at 09:21

1 Answers1

0

According to dropwizard docs you should generate a fat-jar. They include an example of how to do it with maven-shade

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <createDependencyReducedPom>true</createDependencyReducedPom>
        <filters>
            <filter>
                <artifact>*:*</artifact>
                <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                </excludes>
            </filter>
        </filters>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>com.example.helloworld.HelloWorldApplication</mainClass>
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>

Remember to change that com.example.helloworld... class with your project's main class.

isalgueiro
  • 1,973
  • 16
  • 20
  • I already have these fat jars in my pom file. When I create the object of this class in my application it's still null. I tried using @Inject but that's not working either – mia Feb 03 '19 at 23:26