Java 在Dropwizard中添加依赖项
我正在构建一个新的微服务,在这里我必须使用第三方客户端库来解决地理定位问题。 我已经在pom文件中添加了该服务的依赖项Java 在Dropwizard中添加依赖项,java,maven,dropwizard,Java,Maven,Dropwizard,我正在构建一个新的微服务,在这里我必须使用第三方客户端库来解决地理定位问题。 我已经在pom文件中添加了该服务的依赖项 <groupId>abc.xyz.abc.geo</groupId> <artifactId>MyGeoLocation</artifactId> <version>1.5.0</version> </dependency> abc.x
<groupId>abc.xyz.abc.geo</groupId>
<artifactId>MyGeoLocation</artifactId>
<version>1.5.0</version>
</dependency>
abc.xyz.abc.geo
我的地理定位
1.5.0
但是我如何在我的新服务/应用程序中注入此服务的依赖关系呢?根据您应该生成的。其中包括如何使用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>
org.apache.maven.plugins
maven阴影插件
2.3
真的
*:*
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
包裹
阴凉处
com.example.helloworld.helloworld应用程序
记住将com.example.helloworld…
类与项目的主类一起更改。根据需要,您应该生成一个。其中包括如何使用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>
org.apache.maven.plugins
maven阴影插件
2.3
真的
*:*
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
包裹
阴凉处
com.example.helloworld.helloworld应用程序
记得用项目的主类更改
com.example.helloworld…
类。我的pom文件中已经有这些胖罐子了。当我在我的应用程序中创建这个类的对象时,它仍然是空的。我试着使用@Inject,但不起作用。我的pom文件中已经有这些胖罐子了。当我在我的应用程序中创建这个类的对象时,它仍然是空的。我试着使用@Inject,但都不起作用。实际的第三方类是什么样子的?它是为依赖注入设置的吗?Maven依赖项不是DI意义上的依赖项。实际的第三方类是什么样子的?它是为依赖注入设置的吗?Maven依赖项不是DI意义上的依赖项。