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: docs/java-getting-started.md
+28-35Lines changed: 28 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ end
17
17
18
18
<h2data-next-message="I'm ready to start">Introduction</h2>
19
19
20
-
This tutorial will have you deploying a Java app in minutes.
20
+
This tutorial will have you deploying a Java app in minutes.
21
21
22
22
Hang on for a few more minutes to learn how it all works, so you can make the most out of Heroku.
23
23
@@ -71,16 +71,16 @@ Download and run the installer for your platform:
71
71
</div>
72
72
</div>
73
73
74
-
When installation completes, you can use the `heroku` command from your terminal.
74
+
When installation completes, you can use the `heroku` command from your terminal.
75
75
76
76
<divclass="only-windows">On Windows, start the Command Prompt (cmd.exe) or Powershell to access the command shell.</div>
77
77
78
-
Use the `heroku login` command to log in to the Heroku CLI:
78
+
Use the `heroku login` command to log in to the Heroku CLI:
79
79
80
80
```term
81
81
$ heroku login
82
82
heroku: Press any key to open up the browser to login or q to exit
83
-
› Warning: If browser does not open, visit
83
+
› Warning: If browser does not open, visit
84
84
› https://cli-auth.heroku.com/auth/browser/***
85
85
heroku: Waiting for login...
86
86
Logging in... done
@@ -98,11 +98,11 @@ Note that if you’re behind a firewall that requires use of a proxy to connect
98
98
In this step, you will prepare a sample application that's ready to be deployed to Heroku.
99
99
100
100
>callout
101
-
>If you are new to Heroku, it is recommended that you
101
+
>If you are new to Heroku, it is recommended that you
102
102
>complete this tutorial using the Heroku-provided sample application.
103
103
>
104
104
>However, if you have your own existing application that you want to deploy
105
-
>instead, see <ahref="https://devcenter.heroku.com/articles/preparing-a-codebase-for-heroku-deployment"target="_blank">this article</a>
105
+
>instead, see <ahref="https://devcenter.heroku.com/articles/preparing-a-codebase-for-heroku-deployment"target="_blank">this article</a>
106
106
>to learn how to prepare it for Heroku deployment.
107
107
108
108
To create a local copy of a sample app that you can deploy to Heroku, execute the following commands in your local command shell or terminal:
@@ -170,7 +170,7 @@ $ heroku logs --tail
170
170
2017-04-20T15:06:33.778990+00:00 heroku[web.1]: State changed from starting to up
171
171
```
172
172
173
-
Visit your application in the browser again to generate another log message.
173
+
Visit your application in the browser again to generate another log message.
174
174
175
175
Press `CTRL+C` to stop streaming logs.
176
176
@@ -190,7 +190,7 @@ Procfiles can contain additional process types. For example, you might declare o
190
190
191
191
<h2data-next-message="I know how to scale my app">Scale the app</h2>
192
192
193
-
Right now, your app is running on a single web [dyno](dynos). A dyno is a lightweight Linux container that runs the command specified in your `Procfile`.
193
+
Right now, your app is running on a single web [dyno](dynos). A dyno is a lightweight Linux container that runs the command specified in your `Procfile`.
194
194
195
195
You can check how many dynos are running using the `heroku ps` command:
196
196
@@ -200,7 +200,7 @@ You can check how many dynos are running using the `heroku ps` command:
200
200
201
201
By default, your app is deployed on a free dyno. Free dynos sleep after thirty minutes of inactivity (i.e., if they don't receive any traffic). This causes a delay of a few seconds for the first request upon waking. Subsequent requests will perform normally.
202
202
203
-
Free dynos consume from a monthly, account-level quota of [free dyno hours](free-dyno-hours). As long as the quota is not exhausted, your free apps can continue to run.
203
+
Free dynos consume from a monthly, account-level quota of [free dyno hours](free-dyno-hours). As long as the quota is not exhausted, your free apps can continue to run.
204
204
205
205
To avoid dyno sleeping, you can upgrade to a hobby or professional dyno type as described in [Dyno Types](dyno-types). For example, if you migrate your app to a professional dyno, you can easily scale it by running a command telling Heroku to spin up a specific number of dynos, each running your web process type.
206
206
@@ -212,15 +212,15 @@ Scale the number of web dynos to zero:
212
212
:::>- $ heroku ps:scale web=0
213
213
```
214
214
215
-
Access the app again by refreshing your browser or running `heroku open`. You will get an error message because your app no longer has any web dynos available to serve requests.
215
+
Access the app again by refreshing your browser or running `heroku open`. You will get an error message because your app no longer has any web dynos available to serve requests.
216
216
217
217
Scale it up again:
218
218
219
219
```term
220
220
:::>- $ heroku ps:scale web=1
221
221
```
222
222
223
-
To prevent abuse, scaling a non-free application to more than one dyno requires [account verification](account-verification).
223
+
To prevent abuse, scaling a non-free application to more than one dyno requires [account verification](account-verification).
224
224
225
225
<h2data-next-message="I've installed the app dependencies locally">Declare app dependencies</h2>
226
226
@@ -248,7 +248,7 @@ Run `mvn clean install` in your local directory to install the dependencies, pre
248
248
249
249
If you do not have Maven installed, or get an error like `'mvn' is not recognized as an internal or external command`, then you can use the wrapper command instead by running `mvnw clean install` on Windows or `./mvnw clean install` on Mac and Linux. This both installs Maven and runs the Maven command.
250
250
251
-
The Maven process compiles and build a JAR, with dependencies, placing it into your application's `target` directory. This process is accomplished with the `spring-boot-maven-plugin` in the `pom.xml`.
251
+
The Maven process compiles and build a JAR, with dependencies, placing it into your application's `target` directory. This process is accomplished with the `spring-boot-maven-plugin` in the `pom.xml`.
252
252
253
253
If you aren't using Spring in your app, you can accomplish this with the following plugin configuration in the `pom.xml` file.
254
254
@@ -278,7 +278,7 @@ Start your application locally with the `heroku local` CLI command (make sure yo
278
278
279
279
Just like the Heroku platform, `heroku local` examines your `Procfile` to determine what command to run.
280
280
281
-
Open [http://localhost:5000](http://localhost:5000) with your web browser. You should see your app running locally.
281
+
Open [http://localhost:5000](http://localhost:5000) with your web browser. You should see your app running locally.
282
282
283
283
To stop the app from running locally, go back to your terminal window and press `CTRL+C` to exit.
284
284
@@ -378,8 +378,11 @@ Heroku lets you externalize your app's configuration by storing data such as enc
378
378
379
379
At runtime, config vars are exposed to your app as environment variables. For example, modify `src/main/java/com/example/Main.java` so that the method obtains an energy value from the `ENERGY` environment variable:
380
380
381
+
```
382
+
:::-- $ sed -e '56,68d' src/main/java/com/example/Main.java
383
+
```
384
+
381
385
```java
382
-
:::-- sed -e '56,68d' src/main/java/com/example/Main.java
@@ -426,9 +429,7 @@ Deploy your updated application to Heroku to see this in action.
426
429
The `heroku run` command lets you run maintenance and administrative tasks on your app in a [one-off dyno](one-off-dynos). It can also lets you launch a REPL process attached to your local terminal for experimenting in your app's environment, or code that you deployed with your application:
427
430
428
431
```term
429
-
:::-- $ heroku run java -version
430
-
:::-- | grep -vq starting
431
-
:::-> | grep -vq connecting
432
+
:::>> $ heroku run java -version
432
433
```
433
434
434
435
If you receive an error, `Error connecting to process`, then you might need to [configure your firewall](one-off-dynos#timeout-awaiting-process).
@@ -499,11 +500,7 @@ The example app you deployed already has database functionality, which you can r
499
500
The code to access the database is straightforward. Here's the method to insert values into a table called `tick`:
500
501
501
502
```java
502
-
:::-- sed -e '45,49p' src/main/java/com/example/Main.java
503
-
504
-
...
505
-
506
-
:::-- sed -e '66,109p' src/main/java/com/example/Main.java
503
+
:::-> $ sed -n '45,49p;90,109p' src/main/java/com/example/Main.java
507
504
```
508
505
509
506
This ensures that when you access your app using the `/db` route, a new row is added to the `tick` table, and all rows are then returned so that they can be rendered in the output.
@@ -529,22 +526,18 @@ Assuming that you have [Postgres installed locally](heroku-postgresql#local-setu
0 commit comments