[英]Spring boot app endpoints with Azure App service
I'm trying to deploy simple Spring Boot app to Azure App Service, but looks like app doesn't starts.我正在尝试将简单的 Spring 引导应用程序部署到 Azure 应用程序服务,但看起来应用程序没有启动。
My app has on rest endpoint我的应用程序在 rest 端点上
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
I tried to deploy using azure-webapp-maven-plugin, config in pom looks like this我尝试使用 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>
Plugin says deploy was successful, but when i'm opening app webpage - i got 404 error.插件说部署成功,但是当我打开应用程序网页时 - 我收到 404 错误。 The same if I'm deploying using Azure Plugin for Intellij Idea.如果我使用 Intellij Idea 的 Azure 插件进行部署,情况也是如此。
What i'm missing?我错过了什么? Thanks!谢谢!
Please follow this tutorial to deploy: Spring Boot on Linux .请按照本教程进行部署: Spring Boot on Linux 。 I test multiple times, this works for.我测试了多次,这适用。 Or you could just use my pom.xml file.或者你可以使用我的 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>
After deployment, if the web still don't show right page, check the runtime stack if it's same as you defined in the pom.xml.部署后,如果 web 仍然没有显示正确的页面,请检查运行时堆栈是否与您在 pom.xml 中定义的相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.