gpt4 book ai didi

java - 在 Dropwizard 中添加依赖项

转载 作者:太空宇宙 更新时间:2023-11-04 09:52:47 24 4
gpt4 key购买 nike

我正在构建一个新的微服务,我必须使用第三方客户端库来解决地理定位问题。我已在我的 pom 文件中添加了该服务的依赖项

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

但是如何在我的新服务/应用程序中注入(inject)此服务的依赖项?

最佳答案

根据dropwizard docs你应该生成一个 fat-jar 。它们包括如何使用 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>

请记住将 com.example.helloworld... 类更改为您项目的主类。

关于java - 在 Dropwizard 中添加依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54507782/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com