有人能告诉我如何在cmd中使用Intellij和Gradle运行.jar文件吗?
我尝试创建清单文件但收到错误:
N = 10;
A(1:N) = 'a'
或
no main manifest attribute, in eureka-server.jar
我的主要课程:
Error: Could not find or load main class com.project.EurekaServerApplication
Caused by: java.lang.ClassNotFoundException: com.project.EurekaServerApplication
在路径/资源/ META-INF
中的MANIFEST.MF中package com.project;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
我也尝试在build.gradle中
Manifest-Version: 1.0
Main-Class: com.project.EurekaServerApplication
我以这种方式运行这个jar文件:
jar {
manifest {
attributes(
'Main-Class': 'com.project.EurekaServerApplication'
)
}
}
答案 0 :(得分:0)
为了运行.jar文件,你必须在gradle构建之后使其可执行(不管intellij),使用gradle文件中的bootRepackage task:
bootRepackage {
mainClass = 'com.project.EurekaServerApplication'
}