在 Intellij 上通过 SSH 在远程主机上运行测试时无法加载主类 JUnitStarter
我想在另一台功能更强大的机器上运行测试以加快测试时间,因此我在 Intellij 上创建了一个针对我的 Ubuntu 机器而不是本地机器的运行配置。
如果我不使用 rsync 将文件复制到远程目标,则测试一切正常,但是当我在 IntelliJ 中启用 rsync 时,当测试尝试启动时,我会收到以下异常:
Error: Could not find or load main class com.intellij.rt.junit.JUnitStarter
Caused by: java.lang.ClassNotFoundException: com.intellij.rt.junit.JUnitStarter
Process finished with exit code 1
虽然我可以在不启用 rsync 的情况下运行,复制到远程主机的过程比在本地计算机上运行测试花费的时间更长。
对于上下文,我的本地计算机正在运行 Windows 10,而我的远程计算机正在运行 Ubuntu 20.04。
提前致谢!
编辑:
经过更多挖掘后,我发现 rsync 正在使用 MS-DOS 文件结构样式复制 maven 存储库和 Intellij Ultimate 文件夹中的文件。这意味着作为副本的一部分,它使用反斜杠而不是正斜杠,导致 linux 认为它是 .jar 文件名称的一部分。结果,这意味着复制的 Maven 存储库文件夹的文件结构错误:
手动更改文件结构修复了问题并且测试成功运行,但这只是一种解决方法,并不能直接解决问题,但至少在正确的地方 方向。
I'm wanting to run tests on another more powerful machine to speed up testing time, so I've created a run configuration on Intellij which targets my Ubuntu machine rather than my local one.
If I don't use rsync to copy the files to the remote target, the tests all work fine, however when I enable rsync in IntelliJ, I get the following exception when the tests attempt to start:
Error: Could not find or load main class com.intellij.rt.junit.JUnitStarter
Caused by: java.lang.ClassNotFoundException: com.intellij.rt.junit.JUnitStarter
Process finished with exit code 1
Although I could run without rsync enabled, the copy process to the remote host takes longer than running the tests on my local machine.
For context, my local machine is running Windows 10, and my remote machine is running Ubuntu 20.04.
Thanks in advance!
EDIT:
After doing a bit more digging, I found that rsync is copying files in the maven repository and Intellij Ultimate folder using the MS-DOS file structure style. This means that as part of the copy, it's using backslashes instead of forward slashes resulting in linux thinking it's part of the name of the .jar file. In result, it means that the copied maven repository folder is in the wrong file structure:
Changing the file structure manually fixed the issue and tests run successfully however it's just a work around and doesn't directly fix the problem but at least points in the right direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个错误: https://youtrack.jetbrack.jetbrains.com/issue/issue/IDEA-270106
如果您可以投票并将Idea logs附加到那里,将会有所帮助
This is a bug: https://youtrack.jetbrains.com/issue/IDEA-270106
Will be helpful if you can vote for it and attach idea logs there