简体   繁体   English

从不同位置执行 gradle exe 抛出“错误:无法找到或加载主类”

[英]Executing gradle exe from different location throws "Error: Could not find or load main class"

I am new to gradle, I have cloned a project from Github and as mentioned in their QuickGuide I ran ./gradlew build command to build the Gradle exe.So now I navigate to the folder where the exe is created inside the project and execute it via the command ./exe_name param1 param2 .我是 gradle 新手,我从 Github 克隆了一个项目,正如他们的./gradlew build提到的,我运行了./gradlew build命令来构建 Gradle exe。所以现在我导航到在项目中创建 exe 的文件夹并执行它通过命令./exe_name param1 param2 When I have moved the exe to a different location and try to execute the same command , it throws the error Error: Could not find or load main class .当我将 exe 移动到不同的位置并尝试执行相同的命令时,它会抛出错误Error: Could not find or load main class How to resolve this issue ?如何解决这个问题? Like in a fat jar we can mention the main class name inside the jar while execution Thanks就像在一个胖罐子里一样,我们可以在执行时提到罐子里的主类名 谢谢

I'm not really sure, whether your project uses application plugin (or may be spring-boot plugin) or not, but if yes, then you have a root project folder with bin and lib directories within.我不确定您的项目是否使用application插件(或可能是spring-boot插件),但如果是,那么您有一个包含binlib目录的根项目文件夹。

exe file is located in the bin directory and points to the jar -libraries within lib dir, so if you move it somewhere else, you have to move lib directory too, since it contains you project jar and all it's dependencies/ exe文件位于bin目录中并指向lib目录中的jar -libraries,所以如果你将它移动到其他地方,你也必须移动lib目录,因为它包含你的项目 jar 和它的所有依赖项/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM