Maven javax 依赖排除不起作用
Maven javax dependency exclusion doesn't work
我正在尝试使用假客户端实现 OAuth2 密码授权类型。我关注了this guide (only the feign client part). I do it in the separate project (let's call it feign
) and then use it as dependency in the other project
(let's call it like this). The problem is that if I do everything like in the guide, the javax.ws.rs.core.Response
class in the project becomes different from what it was, so one method just disappers. My pom.xml
of feign
if I follow the guide fully (the source code of the guide)
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
</dependencies>
我不需要在这里写版本,因为它们在 pom 依赖中。但是在我这样做之后, project
开始看到其他 javax.ws.rs.core.Response
比以前,我切换分支并比较这两个 类,它们实际上是不同的,我触摸的唯一区别是在 project
中添加 feign
作为依赖项。所以我试图排除 dependencyManagement
并在 feign
:
中手动添加最新版本
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
没用,javax.ws.rs.core.Response
又改了(方法readEntity
消失了)。我假设它在 feign
中的一个依赖项中使用,所以我试图在 project
中手动排除它:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>feign-client</artifact>
<excludes>
<exclude>javax/ws/rs/core/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
<dependency>
<groupId>...</groupId>
<artifactId>feign-client</artifactId>
<version>...</version>
<optional>true</optional>
</dependency>
但它也没有帮助,在 mvn clean install
之后它仍然没有看到方法 readEntity
。有人可以调查一下吗,我如何实现离开旧版本 Response
之前的样子?
通过在依赖 feign
模块之前添加这个依赖来解决:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
我正在尝试使用假客户端实现 OAuth2 密码授权类型。我关注了this guide (only the feign client part). I do it in the separate project (let's call it feign
) and then use it as dependency in the other project
(let's call it like this). The problem is that if I do everything like in the guide, the javax.ws.rs.core.Response
class in the project becomes different from what it was, so one method just disappers. My pom.xml
of feign
if I follow the guide fully (the source code of the guide)
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
</dependencies>
我不需要在这里写版本,因为它们在 pom 依赖中。但是在我这样做之后, project
开始看到其他 javax.ws.rs.core.Response
比以前,我切换分支并比较这两个 类,它们实际上是不同的,我触摸的唯一区别是在 project
中添加 feign
作为依赖项。所以我试图排除 dependencyManagement
并在 feign
:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
没用,javax.ws.rs.core.Response
又改了(方法readEntity
消失了)。我假设它在 feign
中的一个依赖项中使用,所以我试图在 project
中手动排除它:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>feign-client</artifact>
<excludes>
<exclude>javax/ws/rs/core/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
<dependency>
<groupId>...</groupId>
<artifactId>feign-client</artifactId>
<version>...</version>
<optional>true</optional>
</dependency>
但它也没有帮助,在 mvn clean install
之后它仍然没有看到方法 readEntity
。有人可以调查一下吗,我如何实现离开旧版本 Response
之前的样子?
通过在依赖 feign
模块之前添加这个依赖来解决:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>