从应用程序中部署到 Payara

deploy to Payara from within application

我想知道 java 企业应用程序是否可以将另一个应用程序部署到 payara 服务器。我在里面发现了一些东西 Documentation.

import fish.payara.micro.BootstrapException;
import fish.payara.micro.PayaraMicro;
import fish.payara.micro.PayaraMicroRuntime;
import java.io.File;

public class EmbeddedPayara{
    public static void main(String[] args) throws BootstrapException{
        File war = new File("/home/user/deployments/");
        PayaraMicroRuntime instance = PayaraMicro.bootstrap();
        instance.deploy(war);
    }
}

但这适用于 payara micro。我找不到要导入的任何名为 PayaraMicro 的 class。有没有办法在 Payara 中做到这一点?

尽管可以做到这一点,但在 Payara Server 中没有官方方法。

GlassFish API which can be used from a deployed application to deploy other apps. See Deployer Javadoc。 Payara Server 中没有任何变化,因此它应该也适用于 Payara Server。

另一种选择是使用 Cargo project deployer,它也支持 Payara Server(使用 GlassFish 部署器)。它也适用于 Payara Server 之外的任何 Java SE 应用程序,但设置起来更复杂。

另一种选择是使用管理控制台提供的原始 REST 端点,它由 asadmin 工具和 Cargo Deployer 使用。您不需要任何外部依赖,但没有详细记录要访问的资源。这里是 the docs, here's the code of the DeployCommand which describes which parameters it accepts, and here's a path to the deploy endpoint: http://localhost:4848/management/domain/applications/deploy。如果您将 link 粘贴到浏览器,它将提供一个 HTML 前端以供测试。如果您发送接受类型为 JSON 的 post 请求,它将 return 以 JSON 格式响应 (success/failure)