整个org.springframework的Maven依赖 [英] Maven dependency for whole org.springframework

查看:6487
本文介绍了整个org.springframework的Maven依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为所有 org.springframework 设置Maven依赖关系?

How to set Maven dependency for all org.springframework ?

我的意思是,如何做几行,而不是为每个模块提供依赖,例如:

I mean, how to do it in couple lines,instead of providing dependency for every module,e.g.:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>3.0.5.RELEASE</version>
</dependency>

etc ..

谢谢帮助

推荐答案

如其他答案所述,您只想使用您实际需要的内容,例如如果您需要Spring Web框架,那么就可以了。但是,您可以通过执行一些依赖关系分析并仅指定所需依赖关系的最高级别来大大简化和减少pom.xml中列出的依赖项。

As noted in other answers, you only want to use what you actually need, e.g. if you need the Spring Web framework, then get that. However, you can greatly simplify and reduce the set of dependencies listed in your pom.xml by doing a bit of dependency analysis and only specifying the highest level of required dependency.

所以例如,假设你有以下依赖关系(请注意,我正在使用Spring EBR存储库而不是Maven Central的工件ID;请参阅这篇文章有关差异的更多信息):

So for example, suppose you have the following dependencies (note that I'm using the artifact IDs for the Spring EBR repository instead of Maven Central; see this article for more info on the difference):

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>org.springframework.context</artifactId>
    <version>${org.springframework-version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>org.springframework.web.servlet</artifactId>
    <version>${org.springframework-version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>org.springframework.transaction</artifactId>
    <version>${org.springframework-version}</version>
</dependency>

尽管如此,Spring Web内容实际上已经具有对上下文库的依赖,所以您可以删除上下文引用:

As it happens, though, the Spring Web stuff actually already has a dependency on the context library, so you can just remove the context reference:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>org.springframework.web.servlet</artifactId>
    <version>${org.springframework-version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>org.springframework.transaction</artifactId>
    <version>${org.springframework-version}</version>
</dependency>

这将为您提供上下文库,而无需专门引用它,因为它隐含地依赖于Web库。

This will get you the context library without specifically referencing it, since it's brought in implicitly by the dependency in the Web library.

如果您的IDE中有IntelliJ或m2eclipse或类似的内容,则可以通过依赖层次结构显示在IDE中直接显示这些依赖项或者甚至在依赖图中,这基本上是一个UML图表。

If you have IntelliJ or m2eclipse or something like that in your IDE, you can get these dependencies displayed right in the IDE, either through a dependency hierarchy display or even in a dependency graph, which is basically a UML chart.

对于独立的Maven,我想你只是这样做:

For stand-alone Maven, I think you just do:

mvn dependencies:list

关于依赖关系插件的更多内容在插件站点上

这种方法使您的依赖关系非常明确,您的应用程序占用空间更小,这基本上是其他人警告的,但可以减少您在pom中列出的依赖关系数量。 xml,这是我thi nk你正在努力解决。

This approach keeps your dependencies very explicit and your application footprint much smaller, which is basically what everyone else is warning about, but can reduce the number of dependencies you have to list in your pom.xml, which is what I think you're trying to solve.

这篇关于整个org.springframework的Maven依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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