简体   繁体   中英

How to deploy Java Web app on Azure DevOps

I am trying to deploy Java Web app developed in spring boot to Azure Devops. pom.xml and Build Pipeline is also running fine but somehow its not pointing to any internal file structure. We have our classes services and controllers at location /src/main/java/com/corrigo but when adding these in pom.xml its still redirecting to Azures welcome developers page and we have our main starter file at location /src/main/java/com/corrigo/demo/CorrigoModoApplication.java

I think the issue resides in pom.xml. can any one please help me to understand where am I going wrong?

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. 

Since the build/deploy succeed, you should first check if the APP already deploy in Azure.

If there is, you may use the wrong url, so it always redirect to the Azures welcome developers page.

Navigate to the Web App and select the URL from the overview blade. Add /[yourappname] context to the URL. For instance - http://myshuttle1.azurewebsites.net/myshuttledev

More details take a look at this blog-- Deploying a Java-based Tomcat application to Azure

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM