排除配置文件中的依赖 [英] Exclude dependency in a profile

查看:117
本文介绍了排除配置文件中的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有某些依赖项的Maven模块.在某个配置文件中,我想排除其中的某些依赖项(确切地说,是所有具有特定组ID的依赖项).但是,它们必须存在于所有其他配置文件中.有没有一种方法可以指定配置文件的依赖项中的排除项?

I have a maven module which has some dependencies. In a certain profile, I want to exclude some of those dependencies (to be exact, all dependencies with a certain group id). They however need to be present in all other profiles. Is there a way to specify exclusions from the dependencies for a profile?

推荐答案

据我所知,,您无法停用依赖项(可以排除传递性依赖项,但这不是您要的内容和,那么您当前正在使用POM(手动对其进行编辑)是错误的.

To my knowledge, no, you can't deactivate dependencies (you can exclude transitive dependencies but this is not what you are asking for) and yes, what you are currently doing with the POM (manually editing it) is wrong.

因此,除了删除依赖项,您还应该将它们放在配置文件中,并且可以:

So, instead of removing dependencies, you should put them in a profile and either:

  • 选项1:在需要时使用配置文件,或
  • 选项2:默认情况下将配置文件标记为已激活,或将其置于活动配置文件列表中,并在需要时将其停用.

第三个选项是(不基于配置文件):

A third option would be (not profile based):

  • 选项3:在两个分离的模块中分离事物(因为您有不同的关注点)并使用继承.

这篇关于排除配置文件中的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆