如何在 Azure DevOps 上部署 Java Web 应用



我正在尝试将春季启动中开发的Java Web应用程序部署到Azure DevOps.pom.xml和Build Pipeline也运行良好,但不知何故它没有指向任何内部文件结构。我们在位置/src/main/java/com/corrigo 有我们的类服务和控制器,但是 在pom中添加这些内容时.xml它仍然重定向到Azure的欢迎开发人员页面,我们在位置/src/main/java/com/corrigo/demo/CorrigoModoApplication有我们的主启动文件.java

我认为问题出在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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>corrigoModo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>corrigoModo</name>
<description>corrigo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<!-- <src.dir>src/main/java</src.dir> -->
</properties>
<build>
<sourceDirectory>${project.basedir}/src/main/java/com/corrigo</sourceDirectory>
<!--<sourceDirectory>${src.dir}</sourceDirectory>  -->
<!-- <profiles>
<profile>
<id>development</id>
<properties>
<src.dir>${project.build.directory}/com/corrigo</src.dir>
</properties>
</profile>
</profiles> -->
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<forkMode>once</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.9.1</version>
<configuration>
<schemaVersion>V2</schemaVersion>
<resourceGroup>***************</resourceGroup>
<appName>********</appName>
<region>********</region>
<pricingTier>**</pricingTier>
<runtime>
<os>linux</os>
<javaVersion>jre8</javaVersion>
<webContainer>jre8</webContainer>
</runtime>
<!-- Begin of App Settings -->
<appSettings>
<property>
<name>corrigoModo</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
<!-- End of App Settings -->
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- <version>${maven-surefire-plugin.version}</version> -->
<configuration>
<!-- Force alphabetical order to have a reproducible build -->
<runOrder>alphabetical</runOrder>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.medium.article</generatePackage>
<schemaDirectory>src/main/resources/wsdl</schemaDirectory>
<schemaIncludes>
<schemaInclude>*.wsdl</schemaInclude>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.3</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.ws</groupId> <artifactId>spring-ws-security</artifactId> 
</dependency> -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-jwt</artifactId> 
</dependency> -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>4.5</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> 
</dependency> -->
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<!-- <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> 
<version>3.8.1</version> <type>maven-plugin</type> </dependency> -->
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>

<dependency>
<groupId>wss4j</groupId>
<artifactId>wss4j</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>

Build Pipeline is also running fine but somehow its not pointing to any internal file structure. 

由于生成/部署成功,因此应首先检查应用是否已在 Azure 中部署。

如果有,你可能会使用错误的 URL,因此它始终重定向到 Azure 欢迎开发人员页面。

导航到 Web 应用,然后从概述边栏选项卡中选择 URL。将/[yourappname]上下文添加到 URL。例如 -http://myshuttle1.azurewebsites.net/myshuttledev

有关更多详细信息,请查看此博客 - 将基于 Java 的 Tomcat 应用程序部署到 Azure

最新更新