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
+19-18Lines changed: 19 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,9 @@ This tutorial shows how to build, configure, and deploy a secure Tomcat applicat
33
33
34
34
::: zone-end
35
35
36
+
> [!TIP]
37
+
> To try GitHub Copilot, you need a [GitHub Copilot account](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor). A 30-day free trial is available.
38
+
36
39
## Skip to the end
37
40
38
41
You can quickly deploy the sample app in this tutorial and see it running in Azure. Just run the following commands in the [Azure Cloud Shell](https://shell.azure.com), and follow the prompt:
@@ -84,6 +87,12 @@ First, you set up a sample data-driven app as a starting point. For your conveni
84
87
:::column-end:::
85
88
:::row-end:::
86
89
90
+
> [!TIP]
91
+
> You can ask [GitHub Copilot](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor) about this repository. For example:
92
+
>
93
+
> **@workspace What does this project do?*
94
+
> **@workspace What does the .devcontainer folder do?*
95
+
87
96
Having issues? Check the [Troubleshooting section](#troubleshooting).
88
97
89
98
::: zone pivot="azure-portal"
@@ -614,31 +623,23 @@ See [Set up GitHub Actions deployment from the Deployment Center](deploy-github-
614
623
615
624
#### Make code changes using GitHub Copilot
616
625
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?*"
626
+
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. Since GitHub Copilot doesn't give you the same answer every time, the following is just an example:
622
627
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.*"
628
+
1. In your [codespace](#1-run-the-sample), 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*).
625
629
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."
630
+
1. Ask, "*@workspace How does the app connect to the database?*"
628
631
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.*"
632
+
Copilot might give you some explanation about the `jdbc/MYSQLDS` data source and how it's configured. For the `@workspace` agent, see [Use the @workspace agent](https://github.blog/2024-03-25-how-to-use-github-copilot-in-your-ide-tips-tricks-and-best-practices/#10-use-the-workspace-agent).
631
633
632
-
Copilot should update the JNDI name inthe code suggestion.
634
+
1. Ask, "*@workspace I want to replace the data source defined in persistence.xml with an existing JNDI data source in Tomcat but I want to do it dynamically.*"
633
635
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.
636
+
Copilot might show you sample code similar to [the one in this tutorial](#5-deploy-sample-code) and even tell you to make the change in the [ContextListener](https://github.com/Azure-Samples/msdocs-tomcat-mysql-sample-app/blob/starter-no-infra/src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ContextListener.java) class. However, it won't make the actual change for you. It's up to you to add the suggested code and test it.
637
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.
638
+
Here are some other things you can say to fine-tune the answer you get.
639
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.
640
+
* Please change this code to use the data source jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS.
641
+
* Some imports in this are using javax but I have a Jakarta app.
642
+
* I want this code to run only if the environment variable AZURE_MYSQL_CONNECTIONSTRING is set.
0 commit comments