在Maven依赖的编译范围中出现了ClassNotFoundException。

huangapple go评论55阅读模式
英文:

ClassNotFoundException for compile scope in maven dependency

问题

我在我的 pom.xml 中包含了一个第三方的 tomcat jar,使用了 compile 默认范围。它在我的 Eclipse 上正常运行。但是当我在另一台服务器上运行它时,初始化 xml 文件中的一个 bean 类时会出现 ClassNotFoundException 错误。难道 compile 范围的 jar 在运行时不可用吗?

英文:

I have included a third party tomcat jar in my pom.xml with a compile default scope. It runs fine on my machine with Eclipse. But when I run it on another server. It gives ClassNotFoundException while initializing a bean class in xml file. Aren't the compile scoped jar available at runtime as well?

答案1

得分: 1

请注意,仅构建一个 JAR 文件不会包含任何依赖项。这是库所期望的行为。

如果您想要一个可运行的 JAR 文件,您需要使用 Maven Assembly 插件或者 Maven Shade 插件。

英文:

Note that just building a jar will not include any dependencies. This is the desired behaviour for libraries.

If you want a runnable jar, you need to use the maven assembly plugin or the maven shade plugin.

huangapple
  • 本文由 发表于 2020年8月20日 18:03:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/63502736.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定