Skip to content

Commit 1339c34

Browse files
committed
Improve the Java flavor
1 parent 3b154b3 commit 1339c34

File tree

5 files changed

+60
-33
lines changed

5 files changed

+60
-33
lines changed

docs/50-demo-app/2-start-app.mdx

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ To start the application in a codespace, click "Code." Then, look for the *Codes
2121

2222
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/1-codespace.png" alt="Create codespace button" />
2323

24-
</TabItem>
25-
26-
<TabItem value="java" label="☕️ Java Spring Boot">
27-
28-
Open the [repository on the `java-server` branch](https://github.com/mongodb-developer/library-management-system/tree/java-server).
29-
30-
To start the Java application in a codespace, check that you are in the `java-server` branch and then click "Code." Then, look for the *Codespaces* tab. Click "Create Codespace on java-server." This will create a new codespace for you and start the application.
31-
32-
<Screenshot url="https://github.com/mongodb-developer/library-management-system/tree/java-server" src="img/screenshots/50-demo-app/2-start-app/1-codespace-java.png" alt="Create codespace button" />
33-
34-
</TabItem>
35-
</Tabs>
36-
37-
38-
3924
Let it run for a few seconds as it prepares your environment. It will clone the repository, prepare the containers, and run the installation scripts. Once it's ready, you'll see an IDE, with a preview window that shows the running application.
4025

4126
:::note
@@ -58,9 +43,6 @@ Right now, you should see a big error message in the console, as we haven't conf
5843
```
5944
:::
6045

61-
<Tabs groupId="server">
62-
<TabItem value="node" label="🚀 NodeJS/Express">
63-
6446
### Expose the server port
6547

6648
To get the application working in that environment, there is one small change you need to make to the codespace. You need to expose the port where the server is running.
@@ -77,8 +59,30 @@ You'll see the text in the *Visibility* column change to `Public`.
7759

7860
That's it! You're now ready to move to the next section.
7961

62+
8063
</TabItem>
64+
8165
<TabItem value="java" label="☕️ Java Spring Boot">
66+
67+
Open the [repository on the `java-server` branch](https://github.com/mongodb-developer/library-management-system/tree/java-server).
68+
69+
To start the Java application in a codespace, check that you are in the `java-server` branch and then click "Code." Then, look for the *Codespaces* tab. Click "Create Codespace on java-server." This will create a new codespace for you and start the application.
70+
71+
<Screenshot url="https://github.com/mongodb-developer/library-management-system/tree/java-server" src="img/screenshots/50-demo-app/2-start-app/1-codespace-java.png" alt="Create codespace button" />
72+
73+
74+
Let it run for a few seconds as it prepares your environment. It will clone the repository, prepare the containers, and run the installation scripts. Once it's ready, you'll see an IDE, with a preview window that shows the running application.
75+
76+
:::note
77+
Again, this might take a few minutes. It's a great time to grab a coffee. ☕️
78+
:::
79+
80+
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/2-codespace-java.png" alt="The codespace" />
81+
82+
:::warning
83+
Right now, you should see an error message in the console, as we haven't configured the app yet. Don't worry, you'll get it up and running in a few minutes.
84+
:::
85+
8286
### Set the MongoDB connection
8387
To run the application in GitHub Codespaces, you now need to set the MongoDB connection string before starting the server.
8488
In the terminal of your Codespace, run:
@@ -89,12 +93,32 @@ After setting the environment variable, start the application again with:
8993
```Java
9094
mvn spring-boot:run
9195
```
92-
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/5-set-environments.png" alt="The Port Visibility menu" />
96+
97+
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/5-set-environments.png" alt="Set environment variable" />
9398
Once the command finishes, the application will be up and running on port 5000.
94-
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/6-app-started.png" alt="The Port Visibility menu" />
99+
100+
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/6-app-started.png" alt="App is started on port 5000" />
101+
102+
### Expose the server port
103+
104+
To get the application working in that environment, there is one small change you need to make to the codespace. You need to expose the port where the server is running.
105+
106+
Look for the *Ports* tab at the bottom of the IDE.
107+
108+
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/3-ports.png" alt="The Ports tab" />
109+
110+
Once you click on the tab, you'll see a list of ports. Right-click on the port `Server (5000)` row. Then, select "Port Visibility" and "Public."
111+
112+
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/4-port-visibility.png" alt="The Port Visibility menu" />
113+
114+
You'll see the text in the *Visibility* column change to `Public`.
115+
116+
That's it! You're now ready to move to the next section.
117+
95118

96119
</TabItem>
97120
</Tabs>
121+
98122
## 🦸 Option 2: Run locally
99123

100124
If you prefer to run the application locally, you can do so by following these steps. Keep in mind that the following steps of this lab will be using the codespace, so you might need to adapt some of the commands.

docs/50-demo-app/3-configure.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import TabItem from '@theme/TabItem';
44

55
# 👐 Configure the Application
66

7-
Now that your environment is set up, you can configure the application.
8-
There should already be a file open in the IDE. If not, look in the file explorer on the left, and open the file below. This file contains the configuration for the application.
9-
107
<Tabs groupId="server">
118
<TabItem value="node" label="🚀 NodeJS/Express">
129

10+
Now that your environment is set up, you can configure the application.
11+
There should already be a file open in the IDE. If not, look in the file explorer on the left, and open the file below. This file contains the configuration for the application.
12+
1313
File: `server/.env`
1414

1515
```
@@ -39,7 +39,7 @@ In the *Terminal* tab at the bottom, look for the `Server is running on port: 50
3939
</TabItem>
4040

4141
<TabItem value="java" label="☕️ Java Spring Boot">
42-
Everything is set up correctly. You can proceed to the next step.
42+
Verify that your server application is running and the server port is set to "Public".
4343

4444
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/3-configure/1-running-java.png" alt="The terminal panel" />
4545
</TabItem>

docs/70-indexing/1-create-compound-index.mdx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In this exercise, you will build a compound index following the ESR rule, compar
1111
<Tabs groupId="server">
1212
<TabItem value="node" label="🚀 NodeJS/Express">
1313

14-
1. Open the file `server/src/indexing/borrowed-books-index.ts` [file](https://github.com/mongodb-developer/library-management-system/blob/main/server/src/indexing/borrowed-books-index.ts) in your GitHub Codespace.
14+
1. Open the file `server/src/indexing/borrowed-books-index.ts` file in your GitHub Codespace.
1515

1616
2. Examine the code to build a compound index on the `issueDetails` collection.
1717

@@ -81,7 +81,7 @@ In this exercise, you will build a compound index following the ESR rule, compar
8181

8282
<TabItem value="java" label="☕️ Java Spring Boot">
8383

84-
1. Let’s start with our [`IssueDetail`](https://github.com/mongodb-developer/library-management-system/blob/java-server/java-server/src/main/java/com/mongodb/devrel/library/domain/model/IssueDetail.java) record. Right now, it looks like this:
84+
1. Let’s start with our `IssueDetail` record. Right now, it looks like this:
8585
```java title='src/main/java/com/mongodb/devrel/library/domain/model/IssueDetail.java'
8686
@Document(collection = "issueDetails")
8787
public record IssueDetail(
@@ -140,16 +140,19 @@ To double-check that the index was created, you can run the following command in
140140
db.issueDetails.getIndexes()
141141
```
142142

143-
:::info
144-
Optional: If you’re using the MongoDB for VS Code extension
145-
, you can also open the issueDetails collection in the VS Code sidebar and inspect the Indexes tab directly.
146-
:::
147-
148-
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/70-indexing/2-index-vscode.png" alt="VS Code Playground" />
149-
150143
</TabItem>
151144
</Tabs>
152145

146+
## Verify that the index is created
147+
148+
1. Open the **VS Code extension** from the sidebar on the left.
149+
1. Click **Add Connection**.
150+
1. In the welcome screen, click **Connect** under the **Connect with Connection String** section.
151+
1. Enter the MongoDB connection string from your Atlas cluster, making sure to replace the **password placeholder**.
152+
1. Press **Enter**.
153+
1. In the sidebar, you should now see your database. Expand the **library** database, then the **issueDetails** collection, and finally select **Indexes**.
154+
155+
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/70-indexing/2-index-vscode.png" alt="VS Code Extension showing the collection indexes" />
153156

154157
## 🦸‍♀️ Try different indexes
155158

129 KB
Loading
-433 KB
Loading

0 commit comments

Comments
 (0)