[英]Spring boot app endpoints with Azure App service
我正在嘗試將簡單的 Spring 引導應用程序部署到 Azure 應用程序服務,但看起來應用程序沒有啟動。
我的應用程序在 rest 端點上
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
我嘗試使用 azure-webapp-maven-plugin 進行部署,pom 中的配置看起來像這樣
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.7.0</version>
<configuration>
<schemaVersion>V2</schemaVersion>
<!-- Web App information -->
<resourceGroup>${resourceGroup}</resourceGroup>
<appName>boot-test-app</appName>
<region>westeurope</region>
<pricingTier>P1V2</pricingTier>
<runtime>
<os>linux</os>
<javaVersion>jre8</javaVersion>
<webContainer>tomcat 8.5</webContainer>
</runtime>
<appSettings>
<property>
<name>PORT</name>
<value>80</value>
</property>
<property>
<name>JAVA_OPTS</name>
<value>-Xmx512m -Xms512m</value>
</property>
</appSettings>
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<!--<targetPath>/home/site/wwwroot/webapps/ROOT/</targetPath>-->
<includes>
<include>*.war</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
插件說部署成功,但是當我打開應用程序網頁時 - 我收到 404 錯誤。 如果我使用 Intellij Idea 的 Azure 插件進行部署,情況也是如此。
我錯過了什么? 謝謝!
請按照本教程進行部署: Spring Boot on Linux 。 我測試了多次,這適用。 或者你可以使用我的 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-spring-boot</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- tag::actuator[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- end::actuator[] -->
<!-- tag::tests[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- end::tests[] -->
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<schemaVersion>V2</schemaVersion>
<resourceGroup>group name</resourceGroup>
<appName>app name</appName>
<region>westeurope</region>
<pricingTier>P1V2</pricingTier>
<!-- Begin of App Settings -->
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
<runtime>
<os>linux</os>
<javaVersion>jre8</javaVersion>
<webContainer>jre8</webContainer>
</runtime>
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
部署后,如果 web 仍然沒有顯示正確的頁面,請檢查運行時堆棧是否與您在 pom.xml 中定義的相同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.