Payara Micro 웹 애플리케이션을 Azure App Service에서 실행
프로젝트를 MicroProfile Starter에서 만듭니다.
프로젝트에 포함된 코드는 DemoRestApplication.java 및 HelloController.java뿐입니다.
package com.example.demo;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
*
*/
@ApplicationPath("/data")
@ApplicationScoped
public class DemoRestApplication extends Application {
}
package com.example.demo;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
/**
*
*/
@Path("/hello")
@Singleton
public class HelloController {
@GET
public String sayHello() {
return "Hello World";
}
}
코드는 특별히 변경하지 않고 그대로 사용했습니다.
pom.xml의 build 섹션에 다음을 추가합니다.
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.14.0</version>
</plugin>
다음 명령을 실행하여 Linux, Java 11, Tomcat 9.0을 선택했습니다.
mvn com.microsoft.azure:azure-webapp-maven-plugin:1.14.0:config
그런 다음 pom.xml을 다음과 같이 변경합니다.
실제 pom.xml은 여기입니다.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>11</maven.compiler.source>
<payaraVersion>5.2020.2</payaraVersion>
<final.name>demo</final.name>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>3.3</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>demo</finalName>
<plugins>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.14.0</version>
<configuration>
<schemaVersion>v2</schemaVersion>
<subscriptionId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx</subscriptionId>
<resourceGroup>demo-xxxxxxxxxxxxxx-rg</resourceGroup>
<appName>demo-xxxxxxxxxxxxxx</appName>
<pricingTier>P1v2</pricingTier>
<region>westeurope</region>
<runtime>
<os>Linux</os>
<javaVersion>java11</javaVersion>
<webContainer>java11</webContainer>
</runtime>
<appSettings>
<property>
<name>PORT</name>
<value>8080</value>
</property>
<property>
<name>WEBSITES_PORT</name>
<value>8080</value>
</property>
<property>
<name>WEBSITES_CONTAINER_START_TIME_LIMIT</name>
<value>600</value>
</property>
</appSettings>
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>payara-micro</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<version>1.0.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<payaraVersion>${payaraVersion}</payaraVersion>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
나머지는 빌드하고 배포하기만 하면 됩니다.
mvn clean package
mvn com.microsoft.azure:azure-webapp-maven-plugin:1.14.0:deploy
액세스하면 다음과 같이 표시됩니다.
hello 엔드포인트에 액세스하면 Hello World가 표시됩니다.
Reference
이 문제에 관하여(Payara Micro 웹 애플리케이션을 Azure App Service에서 실행), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kikutaro/items/e7a871f455e5f2c077f4텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)