# Payara Micro Embebido

Fuente Diego Silva

Proyecto en github

<https://github.com/avbravo/microtestingclient>

Podemos embeber PayaraMicro dentro de una aplicaciòn Java SE y ejecutarlo directamente.

Crear un proyecto Categories:--> **Maven** Projects:--> **Java Application**&#x20;

![](/files/-Lc1WnPZBwxQaWFlj8A_)

**Nombre:** microtestingclient

![](/files/-Lc1WnPaIoh1fm_m5uRT)

**Dependencias Agregar PayaraMicro**

```
 <dependencies>
        <dependency>
            <groupId>fish.payara.extras</groupId>
            <artifactId>payara-micro</artifactId>
            <version>5.0.0.Alpha3</version>
        </dependency>
  </dependencies>
```

## Crear tres clases

* DeployFromMaven
* DeployWar
* EmbeddedPayara

![](/files/-Lc1WnPcpigZKCFrgqmn)

## DeployFromMaven

Ejecuta Payara Micro, debemos indicar **instance.addDeployFromGAV(Group id, artifact id, version),** revisamos las propiedades del proyecto.

```
instance.addDeployFromGAV("com.avbravo,microtest,0.3");
```

![](/files/-Lc1WnPe6O1_Ihpt_7BS)

```
import fish.payara.micro.BootstrapException;
```

```java
import fish.payara.micro.PayaraMicro;

/**
 *
 * @author avbravo
 */
public class DeployFromMaven {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws BootstrapException {
        // TODO code application logic here
          PayaraMicro instance = PayaraMicro.getInstance();
          instance.setHttpPort(9090);
          instance.addDeployFromGAV("com.avbravo,microtesting,0.1");
          instance.bootStrap();
    }

}
```

## DeployWar

Indicamos la ruta del archivo .war en **instance.addDeployment()**

```java
import fish.payara.micro.BootstrapException;
import fish.payara.micro.PayaraMicro;

/**
 *
 * @author avbravo
 */
public class DeployWar {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws BootstrapException {
        // TODO code application logic here
        PayaraMicro instance = PayaraMicro.getInstance();
        instance.setHttpPort(9090);
       instance.addDeployment("/home/avbravo/NetBeansProjects/testing/microtesting/target/microtesting.war");
        instance.bootStrap();
    }

}
```

## EmbeddedPayara

Ejecutamos PayaraMicro

```java
import fish.payara.micro.BootstrapException;
import fish.payara.micro.PayaraMicro;

/**
 *
 * @author avbravo
 */
public class EmbeddedPayara {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws BootstrapException {
        // TODO code application logic here
         PayaraMicro.bootstrap();//ejecuta PayaraMicro inmediatamente
    }

}
```

Seleccionamos el archivo deseado luego clic derecho y seleccionar Run File

![](/files/-Lc1WnPgLWuI8GTd62oJ)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/payaramicro/payara-micro-embebido.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
