我在 Eclipse 中使用 webapp Artifact 创建了一个 Maven 项目,并在阅读在线教程后将以下行放入 .pom 文件中。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
但是在教程中,版本是 2.5.6。考虑到它是最新版本,我将其替换为 3.0.5.RELEASE。
但是对于这个版本,eclipse 给出了一个错误
Missing artifact org.springframework:spring:jar:3.0.5.RELEASE:compile
这是什么意思?我可以将所需的 jar 文件添加到 lib 文件夹并要求 .pom 文件从那里获取它,因为它是在使用 Ant 的 spring 源网站上的另一个教程中完成的吗?
此外,Maven 项目具有不同的目录结构,似乎比 Ant 在 spring 源代码教程中所做的要多得多。
我对maven完全陌生。实际上只是初学者使用 java 开发 Web 应用程序。我从 spring 源代码做了一些教程,可以在 apache tomcat 上部署和运行 spring mvc hello world 应用程序。为此,我使用了 Ant,并发现它是一个很棒的工具。但是当我从 spring 源代码库中 check out 一些示例应用程序时,似乎 Maven 比 Ant 更受欢迎,也更强大。我发现它有点难以理解。
谢谢
最佳答案
在版本 3 中,Spring 不再提供一体式 Spring jar。
Note: The spring.jar artifact that contained almost the entire framework is no longer provided.
来源:
根据你的项目需要,使用
<dependency>
<groupId>org.springframework</groupId>
<artifactId>${artifactId}</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
${artifactId}
可能是例如
spring-context
(IOC核心,标准ApplicationContext
实现)spring-orm
(ORM 技术:Hibernate、JPA、(I|My)Batis)spring-webmvc
(Spring Web MVC 框架)spring-aop
(面向方面的编程支持)
等等
选定的依赖项将作为传递依赖项引入它们所需的库,因此您通常只需要“最奇特的技术”。例如。如果选择 Spring MVC 和 Spring ORM,还可以获得 AOP、TX、Context、Web 等。
引用:
关于java - 在 maven .pom 中添加 springframework 依赖时,Eclipse 报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4970153/