Maven systemPath 未添加到运行时类路径
我需要添加JDK的tools.jar作为项目依赖项。
将其设置为普通依赖项不起作用,因为将其安装到 Maven 存储库时,它会向 jar 文件添加版本号。此后,当我需要需要 tools.jar 位于类路径中的东西时,它会失败。
使用系统范围并使用 < 设置 jar 的路径系统路径>应该可以解决问题。然而,尽管在测试中 jar 被添加到类路径中,但在运行时却没有。
有办法解决这个问题吗?
顺便说一句,我添加了 < useManifestOnlyJar > false < /useManifestOnlyJar >到surefireplugin,以便我可以看到类路径中的每个文件。
I need to add JDK's tools.jar as a project dependency.
Setting it as a normal dependency is not working, because when installing it to the Maven repository, it adds a version number to the jar file. Thereafter, when I need something that needs tools.jar to be in the classpath, it fails.
Using the system scope and setting the path to the jar using < systemPath > should solve the problem. However, although in tests the jar is added to the classpath, at runtime it is not.
Is there a way around this?
Btw, I've added < useManifestOnlyJar >false< /useManifestOnlyJar > to the surefireplugin so that I can see every file in the classpath.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Maven 是否在 JDK 中运行?
找出它正在运行的 Java 版本,
将 JAVA_HOME 环境变量设置为指向 JDK。
Is Maven running in a JDK?
Find out what version of Java it's running,
Set your JAVA_HOME env variable to point to a JDK.
如果您的 JDK 中未包含它,请使用系统范围,请参阅常见问题解答
if it is not included in your JDK, use system scope, see the FAQ