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

问题描述 投票:0回答:1

我正在尝试将在春季启动中开发的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>

java spring-boot deployment azure-devops pom.xml
1个回答
0
投票
Build Pipeline is also running fine but somehow its not pointing to any internal file structure. 

由于构建/部署成功,因此应首先检查该APP是否已在Azure中部署。

如果存在,则可能使用了错误的URL,因此它总是重定向到Azure欢迎开发人员页面。

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

[更多详细信息请看此博客-Deploying a Java-based Tomcat application to Azure

© www.soinside.com 2019 - 2024. All rights reserved.