From 3002b094f4a26ef42d3c8f70e243d06a9bd431b4 Mon Sep 17 00:00:00 2001 From: Sarah Dutkiewicz Date: Thu, 7 Jul 2022 10:50:05 -0400 Subject: [PATCH 01/12] Updates for the Spring Boot application for Tomcat --- pom.xml | 9 +++++++++ src/main/java/com/example/demo/DemoApplication.java | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 91de33819..36903decd 100644 --- a/pom.xml +++ b/pom.xml @@ -13,10 +13,17 @@ 0.0.1-SNAPSHOT java-docs-spring-hello-world Demo project for Spring Boot + war 11 + + + org.springframework.boot + spring-boot-starter-tomcat + provided + org.springframework.boot spring-boot-starter-web @@ -30,6 +37,8 @@ + + ROOT org.springframework.boot diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java index f594b5bc3..1c5eba242 100644 --- a/src/main/java/com/example/demo/DemoApplication.java +++ b/src/main/java/com/example/demo/DemoApplication.java @@ -2,12 +2,13 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @RestController -public class DemoApplication { +public class DemoApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); From 3f8886de711bfbf70601f52404deef5f279467ae Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:21:21 +0800 Subject: [PATCH 02/12] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/main_connection1.yml | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/main_connection1.yml diff --git a/.github/workflows/main_connection1.yml b/.github/workflows/main_connection1.yml new file mode 100644 index 000000000..f53f89aca --- /dev/null +++ b/.github/workflows/main_connection1.yml @@ -0,0 +1,53 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy WAR app to Azure Web App - Connection1 + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Java version + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Build with Maven + run: mvn clean install + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: java-app + path: '${{ github.workspace }}/target/*.war' + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: java-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'Connection1' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_80328A916B874858ABB656ECB28BB825 }} + package: '*.war' From 335012d97f21e467bd915b537f4e3f0bf66a34b0 Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:26:18 +0800 Subject: [PATCH 03/12] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/main_connection1.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main_connection1.yml b/.github/workflows/main_connection1.yml index f53f89aca..8c9c0086e 100644 --- a/.github/workflows/main_connection1.yml +++ b/.github/workflows/main_connection1.yml @@ -11,7 +11,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v2 @@ -31,7 +31,7 @@ jobs: path: '${{ github.workspace }}/target/*.war' deploy: - runs-on: ubuntu-latest + runs-on: windows-latest needs: build environment: name: 'Production' @@ -49,5 +49,5 @@ jobs: with: app-name: 'Connection1' slot-name: 'Production' - publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_80328A916B874858ABB656ECB28BB825 }} + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_463B5AF1F60B401882554B8341779A71 }} package: '*.war' From d153c68913090d09ed3c22fdbbbc92375d473645 Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Tue, 22 Aug 2023 12:17:18 +0800 Subject: [PATCH 04/12] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/tomcat_connection1.yml | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/tomcat_connection1.yml diff --git a/.github/workflows/tomcat_connection1.yml b/.github/workflows/tomcat_connection1.yml new file mode 100644 index 000000000..731c46e4c --- /dev/null +++ b/.github/workflows/tomcat_connection1.yml @@ -0,0 +1,53 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy WAR app to Azure Web App - Connection1 + +on: + push: + branches: + - tomcat + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Java version + uses: actions/setup-java@v1 + with: + java-version: '8' + + - name: Build with Maven + run: mvn clean install + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: java-app + path: '${{ github.workspace }}/target/*.war' + + deploy: + runs-on: windows-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: java-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'Connection1' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_76849F89CF384C5AB052CF14B6E3DB1F }} + package: '*.war' From a625b231807fb1d9154046f0794b89eef9d15219 Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:02:21 +0800 Subject: [PATCH 05/12] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/tomcat_webapp9972.yml | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/tomcat_webapp9972.yml diff --git a/.github/workflows/tomcat_webapp9972.yml b/.github/workflows/tomcat_webapp9972.yml new file mode 100644 index 000000000..549833778 --- /dev/null +++ b/.github/workflows/tomcat_webapp9972.yml @@ -0,0 +1,53 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy WAR app to Azure Web App - Webapp9972 + +on: + push: + branches: + - tomcat + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Java version + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Build with Maven + run: mvn clean install + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: java-app + path: '${{ github.workspace }}/target/*.war' + + deploy: + runs-on: windows-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: java-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'Webapp9972' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_9F89050EB59748B9A951B90C6750BB40 }} + package: '*.war' From 7d78627d834fd843f23cde2d85e40c903dbb370d Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:14:17 +0800 Subject: [PATCH 06/12] Hello Halim how are you? --- src/main/java/com/example/demo/DemoApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java index 1c5eba242..28e13f8a9 100644 --- a/src/main/java/com/example/demo/DemoApplication.java +++ b/src/main/java/com/example/demo/DemoApplication.java @@ -16,6 +16,6 @@ public static void main(String[] args) { @RequestMapping("/") String sayHello() { - return "Hello World!"; + return "Hello Halim how are you?"; } } From 97bf63fbe71beee43daaebb4aa70e48ea396862f Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:09:53 +0800 Subject: [PATCH 07/12] Create age.java --- src/test/java/com/example/demo/age.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/java/com/example/demo/age.java diff --git a/src/test/java/com/example/demo/age.java b/src/test/java/com/example/demo/age.java new file mode 100644 index 000000000..08d7162e9 --- /dev/null +++ b/src/test/java/com/example/demo/age.java @@ -0,0 +1,21 @@ +import java.time.LocalDate; +import java.time.Period; +import java.util.Scanner; + +public class AgeCalculator { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter your date of birth (YYYY-MM-DD): "); + String dobInput = scanner.nextLine(); + + LocalDate dob = LocalDate.parse(dobInput); + LocalDate currentDate = LocalDate.now(); + + Period age = Period.between(dob, currentDate); + + System.out.println("Your age is: " + age.getYears() + " years, " + age.getMonths() + " months, and " + age.getDays() + " days."); + + scanner.close(); + } +} From 1619f378e9fb14e9794867b0743a2268bf9dd102 Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:16:15 +0800 Subject: [PATCH 08/12] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/age_webage.yml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/age_webage.yml diff --git a/.github/workflows/age_webage.yml b/.github/workflows/age_webage.yml new file mode 100644 index 000000000..74149a5f7 --- /dev/null +++ b/.github/workflows/age_webage.yml @@ -0,0 +1,53 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy WAR app to Azure Web App - webage + +on: + push: + branches: + - Age + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Java version + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Build with Maven + run: mvn clean install + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: java-app + path: '${{ github.workspace }}/target/*.war' + + deploy: + runs-on: windows-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: java-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'webage' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_3DD5BB3BB22949EC93ADE9936963465A }} + package: '*.war' From 6e5a963bda16959ff52e7ea49db67fa9f3ca8f7a Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:23:17 +0800 Subject: [PATCH 09/12] Delete DemoApplicationTests.java --- .../java/com/example/demo/DemoApplicationTests.java | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 src/test/java/com/example/demo/DemoApplicationTests.java diff --git a/src/test/java/com/example/demo/DemoApplicationTests.java b/src/test/java/com/example/demo/DemoApplicationTests.java deleted file mode 100644 index 2778a6a7e..000000000 --- a/src/test/java/com/example/demo/DemoApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.demo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class DemoApplicationTests { - - @Test - void contextLoads() { - } - -} From a44a96684e102474e53fae1765989621ee8541df Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:24:31 +0800 Subject: [PATCH 10/12] Delete src/main/java/com/example/demo directory --- .../com/example/demo/DemoApplication.java | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 src/main/java/com/example/demo/DemoApplication.java diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java deleted file mode 100644 index 28e13f8a9..000000000 --- a/src/main/java/com/example/demo/DemoApplication.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.example.demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@SpringBootApplication -@RestController -public class DemoApplication extends SpringBootServletInitializer { - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - } - - @RequestMapping("/") - String sayHello() { - return "Hello Halim how are you?"; - } -} From 4502eaf70d701c45910dbec61dec29ee07b4ae52 Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:25:13 +0800 Subject: [PATCH 11/12] Delete src/main/resources directory --- src/main/resources/application.properties | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/main/resources/application.properties diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b1378917..000000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - From 834ea5963f7292ae7b0c64c0c6ab553f278d9824 Mon Sep 17 00:00:00 2001 From: Shashankcsjax <142861535+Shashankcsjax@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:32:24 +0800 Subject: [PATCH 12/12] Update age.java --- src/test/java/com/example/demo/age.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/com/example/demo/age.java b/src/test/java/com/example/demo/age.java index 08d7162e9..26d3a61db 100644 --- a/src/test/java/com/example/demo/age.java +++ b/src/test/java/com/example/demo/age.java @@ -1,3 +1,10 @@ +package com.example.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import java.time.LocalDate; import java.time.Period; import java.util.Scanner;