简体   繁体   English

如何使用腻子从Linux运行Spring Boot应用程序

[英]how to run a spring boot application from linux using putty

I am not able to run a spring boot application (main class) from UNIX using putty with could not find or load main class error. 我无法使用腻子从UNIX运行UNIX的Spring Boot应用程序(主类),但找不到或加载主类错误。

All files are given 0755 executable permissions under the project folder. 在项目文件夹下,所有文件都被授予0755可执行权限。 Tried using command: java -cp .:batch-services.jar:lib/* com.spring.integration.demo.SpringBootDemoApplication 使用以下命令进行了尝试:java -cp。:batch-services.jar:lib / * com.spring.integration.demo.SpringBootDemoApplication

Running command from the path: /app/batch 从以下路径运行命令:/ app / batch

Folder structure in UNIX: UNIX中的文件夹结构:

/app/batch/lib - this folder has all the dependency jars / app / batch / lib-此文件夹包含所有依赖项jar

/app/batch/batch-services.jar /app/batch/batch-services.jar

Expected result is that the spring boot application will start successfully. 预期结果是spring boot应用程序将成功启动。

Actual result is: 实际结果是:

Error: Could not find or load main class com.spring.integration.demo.SpringBootDemoApplication 错误:找不到或加载主类com.spring.integration.demo.SpringBootDemoApplication

It looks like you have encountered a common issue with how Java interacts with shell wildcards (asterisks). 看来您遇到了Java与Shell通配符(星号)交互的常见问题。 Java expects your classpath elements to be separated by colons, but your shell generates spaces. Java希望您的类路径元素由冒号分隔,但是您的shell会生成空格。

The solution is to quote the argument. 解决方案是引用参数。 See this answer: Including all the jars in a directory within the Java classpath 看到这个答案: 在Java类路径的目录中包含所有jar

Also, if you are using spring-boot, you can build your application into a so called fat-jar. 另外,如果您使用的是spring-boot,则可以将应用程序构建到所谓的fat-jar中。

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

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