【问题标题】:Maven dependency scope conflict with Eclipse scopeMaven 依赖范围与 Eclipse 范围冲突
【发布时间】:2014-02-24 08:53:02
【问题描述】:

当我在 Eclipse 中将 maven 依赖声明为 runtime 时,额外的 jar 会在部署时复制到 tomcat。在compile 我有部署错误,因为没有库。 Eclipse 总是编译没有错误。

但是,当我想只使用 Maven (mvn compile) 构建同一个项目时,编译时 runtime 依赖项不在类路径中,所以我有编译错误。

这导致我必须只使用其中一种工具进行编译或维护两个pom.xml 文件。

关于pom.xml 依赖项的任何解决方案都可用于mvn 命令编译并使用Eclipse 部署到运行时环境?

【问题讨论】:

  • 如果您提供一些额外的信息,帮助会更容易。你的编译错误是什么?你的 Eclipse .classpath 中有什么?你的 pom 中有哪些依赖项?两者匹配吗?

标签: java eclipse maven tomcat dependencies


【解决方案1】:

如果编译需要依赖项,为什么要将它们声明为runtime

runtime
This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.

【讨论】:

  • 如果我设置compile 范围,Eclipse 不会将它与项目类和 JSP 一起部署到 tomcat。使用runtime - 确实如此。
猜你喜欢
  • 2019-08-23
  • 1970-01-01
  • 1970-01-01
  • 2013-05-28
  • 2013-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-28
相关资源
最近更新 更多