设置Quarkus的程序入口

使用这个@QuarkusMain注解即可

@QuarkusMain
public class ApplicationStart {

    public static void main(String[] args) {
        System.out.println(111);
    }

}

增加了这个注解之后,接着如果你对整个项目编译成可执行程序,然后进行执行,则会看到输出111

这个注解 的含义是:

The default main class of a Quarkus application. There are two different ways this annotation can be used. The first is to place it on a class with a Java main method. This main method will be the default entry point of the application. Note that Quarkus will not be started when this method is called, this method must launch Quarkus with the io.quarkus.runtime.Quarkus.run(Class, String...) method. Alternatively this annotation can be placed on an io.quarkus.runtime.QuarkusApplication implementation. In this case a main method is automatically generated that will automatically call io.quarkus.runtime.Quarkus.run(Class, String...) with the provided application. Note that this can be overridden by the presence of the quarkus.package.main-class configuration key. If this configuration key is used it can either specify the fully qualified name of a class with a Java main method, the fully qualified name of a io.quarkus.runtime.QuarkusApplication, or the name as given by name().

说的是:

Quarkus应用程序的默认主类。该注解有两种不同的使用方式。第一种方式是将其放置在一个带有Java主方法的类上。该主方法将成为应用程序的默认入口点。请注意,当调用此方法时,Quarkus不会启动,此方法必须使用io.quarkus.runtime.Quarkus.run(Class, String...)方法来启动Quarkus。另外,该注解也可以放置在io.quarkus.runtime.QuarkusApplication的实现类上。在这种情况下,将自动生成一个主方法,该方法将自动使用提供的应用程序调用io.quarkus.runtime.Quarkus.run(Class, String...)。请注意,通过quarkus.package.main-class配置键可以覆盖此行为。如果使用此配置键,它可以指定具有Java主方法的类的完全限定名称、io.quarkus.runtime.QuarkusApplication的完全限定名称,或者通过name()指定的名称。

# Java  quarkus 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×