使用gradle build项目报错:Main class name has not been configured and it could not 问题处理

Execution failed for task ‘:api:bootJar’.

> Main class name has not been configured and it could not

这里记录一个Bug处理:

Task :api:bootJar FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:api:bootJar’.

Main class name has not been configured and it could not be resolved

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6s
2 actionable tasks: 2 executed
使用gradle build项目报错:Main class name has not been configured and it could not 问题处理_第1张图片
引起原因是:api子模块没有启动类,为其添加一个启动类即可!
使用gradle build项目报错:Main class name has not been configured and it could not 问题处理_第2张图片
这个是我刚加上的启动类:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 启动类
 *
 * 此类不做任何启动使用,如果不加此类build会报错:
 */
@SpringBootApplication
public class Bootstrap {

    /**
     * Spring Boot 启动入口
     *
     * @param args 参数列表
     */
    public static void main(String[] args) {
        final Logger LOGGER = LoggerFactory.getLogger(Bootstrap.class);
        try {
            SpringApplication.run(Bootstrap.class, args);
        } catch (Throwable e) {
            LOGGER.error("系统异常", e);
        }
    }
}

再次clean–build
使用gradle build项目报错:Main class name has not been configured and it could not 问题处理_第3张图片
成功解决!!!

欢迎大佬们留言评论,共同学习!!!感谢!!!

===========================
原创文章,转载注明出处!

你可能感兴趣的:(Bug记录)