intellj IDEA无法正确构建jar [英] intellj IDEA doesnt build jar properly

查看:57
本文介绍了intellj IDEA无法正确构建jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了

我保留了默认选项

使用intellij版本进行测试

不起作用

不起作用

使用Spring Boot中提供的内部版本进行测试

有效

I followed this "tutorial" to build a jar from a project in intellj. The project includes a small spring application, that works running from intellij itself.

If I build the jar and run it from the command line, it says "Error: Could not find or load main class". If I run the main.class file using java .\main.class, the same Message shows up.

I specified the Main class in Intellij-IDEA before building the Jar, and the Main.java file looks something like this:

@SpringBootApplication
@RestController
public class Main {

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }


    @GetMapping("/index")
    public String index() {
           . . . .
    }
}

解决方案

I performed some test

So I created a new project

I left the default options

test with the intellij build

not work

not work

test with the build provided in spring boot

it works

这篇关于intellj IDEA无法正确构建jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆