英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论