intellij IDEA 无法正确构建 jar
intellj IDEA doesnt build jar properly
我按照 this“教程”从 intellj 中的一个项目构建了一个 jar。该项目包括一个小型 spring 应用程序,它 运行 从 intellij 本身运行。
如果我构建 jar 并从命令行 运行 它,它会显示“错误:无法找到或加载 main class”。如果我 运行 使用 java .\main.class
的 main.class 文件,会出现相同的消息。
我在构建 Jar 之前在 Intellij-IDEA 中指定了 Main class,Main.java 文件看起来像这样:
@SpringBootApplication
@RestController
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
@GetMapping("/index")
public String index() {
. . . .
}
}
我进行了一些测试
所以我创建了一个新项目
我保留了默认选项
使用 intellij 构建进行测试
不工作
不工作
使用 spring 引导中提供的构建进行测试
有效
我忘了告诉你
您可以在 intellij 中创建订单
更改配置并通过按播放按钮从 Intellij 启动命令
我按照 this“教程”从 intellj 中的一个项目构建了一个 jar。该项目包括一个小型 spring 应用程序,它 运行 从 intellij 本身运行。
如果我构建 jar 并从命令行 运行 它,它会显示“错误:无法找到或加载 main class”。如果我 运行 使用 java .\main.class
的 main.class 文件,会出现相同的消息。
我在构建 Jar 之前在 Intellij-IDEA 中指定了 Main class,Main.java 文件看起来像这样:
@SpringBootApplication
@RestController
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
@GetMapping("/index")
public String index() {
. . . .
}
}
我进行了一些测试
所以我创建了一个新项目
我保留了默认选项
使用 intellij 构建进行测试
不工作
不工作
使用 spring 引导中提供的构建进行测试
有效
我忘了告诉你
您可以在 intellij 中创建订单
更改配置并通过按播放按钮从 Intellij 启动命令