You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/tutorial-java-tomcat-mysql-app.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,6 +207,9 @@ In this step, you configure GitHub deployment using GitHub Actions. It's just on
207
207
208
208
Like the Tomcat convention, if you want to deploy to the root context of Tomcat, name your built artifact *ROOT.war*.
209
209
210
+
> [!TIP]
211
+
> In **Step 4**, try [letting GitHub Copilot show you the code changes to make](#make-code-changes-using-github-copilot).
212
+
210
213
:::row:::
211
214
:::column span="2":::
212
215
**Step 1:** Back in the App Service page, in the left menu, select **Deployment Center**.
@@ -482,6 +485,9 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
482
485
483
486
This code checks to see if the `AZURE_MYSQL_CONNECTIONSTRING` app setting exists, and changes the data source to `java:comp/env/jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS`, which is the data source you found earlier in*context.xml*in the SSH shell.
484
487
488
+
> [!TIP]
489
+
> Try [letting GitHub Copilot show you the code changes to make](#make-code-changes-using-github-copilot).
490
+
485
491
1. Back in the codespace terminal, run `azd deploy`.
486
492
487
493
```bash
@@ -606,6 +612,34 @@ git push origin main
606
612
607
613
See [Set up GitHub Actions deployment from the Deployment Center](deploy-github-actions.md#set-up-github-actions-deployment-from-the-deployment-center).
608
614
615
+
#### Make code changes using GitHub Copilot
616
+
617
+
With a [GitHub Copilot account](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor) (30-day free trial available), you can make the code changes in this tutorial by using Copilot Chat in the codespace. For example:
618
+
619
+
1. In your [codespace](#1-run-the-sample), open *src/main/resources/META-INF/persistence.xml*.
620
+
1. Start a new Copilot chat session in the **Chat** view. The GitHub Copilot chat extension was installed by the container definition (see *.devcontainer/devcontainer.json*).
621
+
1. If you like, ask, "*What does this file do?*"
622
+
623
+
Copilot should give you some explanation about the jdbc/MYSQLDS data source.
624
+
1. Ask, "*I want to override this data source dynamically with a Tomcat shared data source.*"
625
+
626
+
Copilot should show you sample code similar to [the one in this tutorial](#5-deploy-sample-code).
627
+
1. If the sample code is using the `javax.*` namespace, you can say "My application uses Jakarta instead."
628
+
629
+
Copilot should update the code suggestion to use the `jakarta.persistence.nonJtaDataSource` instead.
630
+
1. Say, "*My Tomcat data source is called jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS.*"
631
+
632
+
Copilot should update the JNDI name in the code suggestion.
633
+
634
+
1. Say, "*I want this code to run only if the environment AZURE_MYSQL_CONNECTIONSTRING is set.*"
635
+
636
+
Copilot should update the code suggestion with a check for the environment variable.
637
+
638
+
The suggested code for`contextInitialized` is now very similar to the one shownin this tutorial. It may not be exactly the same. You can copy and paste this code into the `contextInitialized` method of *src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ContextListener.java* and test it.
639
+
640
+
> [!NOTE]
641
+
> Copilot is not always correct in its code suggestions. It's still up to you to verify that the code works as expected in your application.
0 commit comments