gpt4 book ai didi

java - 在 tomcat 7/maven 嵌入式 tomcat 上运行 Spring 3.1 webapp

转载 作者:行者123 更新时间:2023-11-28 22:06:55 26 4
gpt4 key购买 nike

我刚刚从 Spring 3.0.6 升级到 3.1,在 Tomcat 上运行它似乎有问题。显然它有一个 Spring 3.0.6 依赖项,并且会在启动时尝试使用它。然而,这与我的 Spring 3.1 应用程序冲突。我在尝试通过

进行部署时得到了这个
mvn clean package tomcat:run

以及尝试在 Tomcat 7 中运行它时(通过 Eclipse 或将其复制到 tomcat webapps 文件夹)

这里的解决方案是什么?升级到 Maven 3 可能有帮助吗? maven Tomcat-plugin 怎么样?到目前为止,1.1 已经发布,但版本 2 似乎仍在开发中。有没有人有使用 2.x 版本的 tomcat 插件的 pom 设置?

(我当前的错误日志基本上是这样说的:

java.lang.NoClassDefFoundError: org/springframework/core/annotation/AnnotationAttributes

这显然是 Spring 3.1 和 3.0.x 之间的版本冲突)

我完全迷失在这个问题上,一整天都在尝试解决我模块中的依赖困惑,将它们升级到 3.1,所有测试都运行,但现在我无法在 Tomcat 上运行它。: (


编辑:我的 spring 依赖树:

 module1:jar:1.0-SNAPSHOT:compile
+- modul2:jar:1.0-SNAPSHOT:compile
| +- module3:jar:1.1-SNAPSHOT:compile
| | +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
| | +- org.springframework:spring-beans:jar:3.1.0.RELEASE:compile
| | +- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
| | +- org.springframework:spring-aspects:jar:3.1.0.RELEASE:compile
| | +- org.springframework:spring-orm:jar:3.1.0.RELEASE:compile
| | | +- org.springframework:spring-jdbc:jar:3.1.0.RELEASE:compile
| | | \- org.springframework:spring-tx:jar:3.1.0.RELEASE:compile
| | \- org.springframework:spring-core:jar:3.1.0.RELEASE:compile
| +- org.springframework:spring-webmvc:jar:3.1.0.RELEASE:compile
| | +- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
| | +- org.springframework:spring-context-support:jar:3.1.0.RELEASE:compile
| | +- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
| | \- org.springframework:spring-web:jar:3.1.0.RELEASE:compile
| \- org.springframework:spring-test:jar:3.1.0.RELEASE:compile
\- org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT:test

编辑 2:

出于某些奇怪的原因,当我从 .m2 文件夹中删除所有 Spring 3.0.6 库然后打包 webapp 时,它将再次下载所有 3.0.6 jar。然而,依赖树是上面的那个。我认为它与 spring-security 有关,它与版本有一些问题,需要我覆盖我的安全模块 pom 中的 transient 依赖关系,这样它就不会使用旧的......


编辑 3:

它是 spring-data-jpa。显然最新版本仍然依赖于 Spring 3.0.6。我可以通过覆盖 pom 中的依赖项使其与 Spring 3.1 一起运行,因此测试可以运行。但是,当将我的数据模块集成到我的 webapp 中时,它将尝试使用 Spring 3.0.6...不知道如何解决该问题。甚至是 spring-data-jpa (version 1.1.0.RC1) 的最新 Realase Candidate|仍然依赖于 Spring 3.0.7...

最佳答案

在控制台上执行:

mvn dependency:tree -Dincludes=org.springframework,org.springframework.security

这将列出 Spring Artifact 的所有依赖路径。我很确定您对某个地方的某个 Spring 3.0.x Artifact 有传递依赖性。 Maven 和 Tomcat 都没有任何 Spring 依赖项!

您可以检查的另一件事是文件夹

src/main/webapp/WEB-INF/lib

如果它存在(在 maven webapp 中通常不应该存在),它可能包含一个旧的 Spring Jar。删除那个。

关于java - 在 tomcat 7/maven 嵌入式 tomcat 上运行 Spring 3.1 webapp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10934905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com