简体   繁体   English

spring-boot-maven-plugin创建的jar通过使用classpath运行

[英]spring-boot-maven-plugin created jar run by using classpath

used spring-boot-maven-plugin to build my jar, i'm to run it via 用spring-boot-maven-plugin构建我的jar,我要通过它运行

java -jar  myExample-1.0-SNAPSHOT.jar

but it throw error 但它抛出错误

Error: Could not find or load main class com.manish.myexample.Example 错误:找不到或加载主类com.manish.myexample.Example

while running via 通过运行时

java -cp  myExample-1.0-SNAPSHOT.jar com.manish.myexample.Example

is because of spring-boot-maven-plugin ? 是因为spring-boot-maven-plugin吗? and even tried 甚至尝试过

java -cp  libs/myExample-1.0-SNAPSHOT.jar: BOOT-INF.classes.com.manish.myexample.Example

You must ensure that you add the location of your .class file to your classpath. 您必须确保将.class文件的位置添加到类路径中。 That is usually first mistake. 通常这是第一个错误。

...and some general reasons why Java cannot find the class: ...以及Java无法找到该类的一些一般原因:

  1. you made a mistake with the classname argument; 您在classname参数上犯了一个错误;
  2. the application's classpath is incorrectly specified: the wrong directory is on the classpath, the subdirectory path doesn't match or dependencies missing from the classpath; 应用程序的类路径指定不正确:类路径上的目录错误,子目录路径不匹配或类路径中缺少依赖项;
  3. the class has been declared in the wrong package. 该类已在错误的包中声明。

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

相关问题 在 spring-boot-maven-plugin 打包的 jar 中使用 ClassPath.getTopLevelClasses() 查找类 - Finding classes with ClassPath.getTopLevelClasses() in jar packaged by spring-boot-maven-plugin spring-boot-maven-plugin 创建具有依赖项的 jar - spring-boot-maven-plugin create jar with dependencies spring-boot-maven-plugin 不会创建 fat jar - spring-boot-maven-plugin doesn't create fat jar 为什么 Java -cp 选项在使用 spring-boot-maven-plugin 时 -jar 不起作用? - Why is the Java -cp option not working when -jar does while using the spring-boot-maven-plugin? 使用 spring-boot-maven-plugin 从依赖 jar 拆分版本号? - Spliting version number from dependency jar using spring-boot-maven-plugin? 无法在 spring-boot-maven-plugin 中分叉 - Unable to fork in spring-boot-maven-plugin spring-boot-maven-plugin:加载在哪里? - spring-boot-maven-plugin: where it is loaded? Maven - 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.1:run - Maven - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:run 将像Minify-Maven-plugin这样的Resource Compressor集成到spring-boot-maven-plugin中:运行热重载 - Integrating Resource Compressor like minify-maven-plugin into spring-boot-maven-plugin:run hot reloading Spring DevTools 未包含在 spring-boot-maven-plugin 打包的 fat jar 中 - Spring DevTools not included in the fat jar packaged with spring-boot-maven-plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM