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
title: Quickstart to learn how to use Azure App Configuration
3
3
description: In this quickstart, create a Java Spring app with Azure App Configuration to centralize storage and management of application settings separate from your code.
4
4
services: azure-app-configuration
5
-
documentationcenter: ''
6
5
author: mrm9084
7
-
editor: ''
8
6
ms.service: azure-app-configuration
9
7
ms.devlang: java
10
8
ms.topic: quickstart
11
-
ms.date: 05/02/2022
9
+
ms.date: 02/22/2023
12
10
ms.custom: devx-track-java, mode-api
13
11
ms.author: mametcal
14
12
#Customer intent: As a Java Spring developer, I want to manage all my app settings in one place.
15
13
---
14
+
16
15
# Quickstart: Create a Java Spring app with Azure App Configuration
17
16
18
17
In this quickstart, you incorporate Azure App Configuration into a Java Spring app to centralize storage and management of application settings separate from your code.
@@ -22,171 +21,153 @@ In this quickstart, you incorporate Azure App Configuration into a Java Spring a
22
21
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
23
22
- A supported [Java Development Kit (JDK)](/java/azure/jdk) with version 11.
24
23
-[Apache Maven](https://maven.apache.org/download.cgi) version 3.0 or above.
24
+
- A Spring Boot application. If you don't have one, create a Maven project with the [Spring Initializr](https://start.spring.io/). Be sure to select **Maven Project** and, under **Dependencies**, add the **Spring Web** dependency, and then select Java version 8 or higher.
7. Select **Configuration Explorer** > **+ Create** > **Key-value** to add the following key-value pairs:
31
-
32
-
| Key | Value |
33
-
|---|---|
34
-
| /application/config.message | Hello |
35
-
36
-
Leave **Label** and **Content Type** empty for now.
37
-
38
-
8. Select **Apply**.
39
-
40
-
## Create a Spring Boot app
30
+
9. Select **Configuration Explorer** > **+ Create** > **Key-value** to add the following key-value pairs:
41
31
42
-
To create a new Spring Boot project:
32
+
| Key | Value |
33
+
|---|---|
34
+
| /application/config.message | Hello |
43
35
44
-
1. Browse to the [Spring Initializr](https://start.spring.io).
36
+
Leave **Label** and **Content Type** empty for now.
45
37
46
-
1. Specify the following options:
47
-
48
-
- Generate a **Maven** project with **Java**.
49
-
- Specify a **Spring Boot** version that's equal to or greater than 2.0.
50
-
- Specify the **Group** and **Artifact** names for your application.
51
-
- Add the **Spring Web** dependency.
52
-
53
-
1. After you specify the previous options, select **Generate Project**. When prompted, download the project to a path on your local computer.
38
+
10. Select **Apply**.
54
39
55
40
## Connect to an App Configuration store
56
41
57
-
1. After you extract the files on your local system, your simple Spring Boot application is ready for editing. Locate the *pom.xml* file in the root directory of your app.
58
-
59
-
1. Open the *pom.xml* file in a text editor, and add the Spring Cloud Azure Config starter to the list of `<dependencies>`:
60
-
61
-
**Spring Boot 2.6**
42
+
Now that you have an App Configuration store, you can use the Spring Cloud Azure Config starter to have your application communicate with the App Configuration store that you create.
To install the Spring Cloud Azure Config starter module, add the following dependency to your *pom.xml* file:
70
45
71
-
> [!NOTE]
72
-
> If you need to support an older version of Spring Boot see our [old library](https://github.com/Azure/azure-sdk-for-java/blob/spring-cloud-starter-azure-appconfiguration-config_1.2.9/sdk/appconfiguration/spring-cloud-starter-azure-appconfiguration-config/README.md).
1. Create a new Java file named *MessageProperties.java* in the package directory of your app. Add the following lines:
54
+
> [!NOTE]
55
+
> If you need to support an older version of Spring Boot, see our [old library](https://github.com/Azure/azure-sdk-for-java/blob/spring-cloud-starter-azure-appconfiguration-config_1.2.9/sdk/appconfiguration/spring-cloud-starter-azure-appconfiguration-config/README.md).
To use the Spring Cloud Azure Config starter to have your application communicate with the App Configuration store that you create, configure the application by using the following steps.
80
60
81
-
@ConfigurationProperties(prefix = "config")
82
-
public class MessageProperties {
83
-
private String message;
61
+
1. Create a new Java file named *MessageProperties.java*, and add the following lines:
1. In the main application Java file, add `@EnableConfigurationProperties` to enable the *MessageProperties.java* configuration properties class to take effect and register it with the Spring container.
1. Set an environment variable named **APP_CONFIGURATION_CONNECTION_STRING**, and set it to the access key to your App Configuration store. At the command line, run the following command and restart the command prompt to allow the change to take effect:
0 commit comments