如何通过命令行启动spring-boot应用程序? [英] How to start up spring-boot application via command line?

查看:71
本文介绍了如何通过命令行启动spring-boot应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个spring-boot应用程序,我需要通过转到文件夹目录来启动并通过命令行启动我的Web应用程序.我有一个名为Application.java的类,其内部的代码如下.

I have a spring-boot application which I need to start up by going to the folder directory and start up my web application via command line. I have a class called Application.java and the code inside it is as followed.

@SpringBootApplication(scanBasePackages = {"com.ubs.tas.topcat.dashboard"})
public class Application extends SpringBootServletInitializer {
    private static final Logger LOGGER = LoggerFactory.getLogger(Application.class.getName());
    private static final Class<Application> applicationClass = Application.class;

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(applicationClass);
    }

    public static void main(String[] args) {
        LOGGER.info("Starting...");
        SpringApplication.run(Application.class, args);
    }
}

我设置了类路径,然后尝试运行命令" java ApplicationUtility ",但我收到此错误消息"找不到主类:ApplicationUtility.程序将存在."

I set up classpath then tried to run the command "java ApplicationUtility" but I'm getting this error message "Could not find the main class: ApplicationUtility. Program will exist."

推荐答案

您将需要先构建jar文件.这是从jar文件运行主类的语法.

You will need to build the jar file first. Here is the syntax to run the main class from a jar file.

java -jar path/to/your/jarfile.jar fully.qualified.package.Application 

这篇关于如何通过命令行启动spring-boot应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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