Skip to content

Commit 38823c7

Browse files
authored
Merge pull request heroku#73 from heroku/spring-2.0.7
Spring 2.0.7
2 parents edc690c + 280d6ab commit 38823c7

File tree

2 files changed

+48
-58
lines changed

2 files changed

+48
-58
lines changed

docs/java-getting-started.md

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717

1818
<h2 data-next-message="I'm ready to start">Introduction</h2>
1919

20-
This tutorial will have you deploying a Java app in minutes.
20+
This tutorial will have you deploying a Java app in minutes.
2121

2222
Hang on for a few more minutes to learn how it all works, so you can make the most out of Heroku.
2323

@@ -71,16 +71,16 @@ Download and run the installer for your platform:
7171
</div>
7272
</div>
7373

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.
7575

7676
<div class="only-windows">On Windows, start the Command Prompt (cmd.exe) or Powershell to access the command shell.</div>
7777

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:
7979

8080
```term
8181
$ heroku login
8282
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
8484
› https://cli-auth.heroku.com/auth/browser/***
8585
heroku: Waiting for login...
8686
Logging in... done
@@ -98,11 +98,11 @@ Note that if you’re behind a firewall that requires use of a proxy to connect
9898
In this step, you will prepare a sample application that's ready to be deployed to Heroku.
9999

100100
>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
102102
>complete this tutorial using the Heroku-provided sample application.
103103
>
104104
>However, if you have your own existing application that you want to deploy
105-
>instead, see <a href="https://devcenter.heroku.com/articles/preparing-a-codebase-for-heroku-deployment" target="_blank">this article</a>
105+
>instead, see <a href="https://devcenter.heroku.com/articles/preparing-a-codebase-for-heroku-deployment" target="_blank">this article</a>
106106
>to learn how to prepare it for Heroku deployment.
107107
108108
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:
@@ -111,6 +111,9 @@ To create a local copy of a sample app that you can deploy to Heroku, execute th
111111
```term
112112
:::>- $ git clone https://github.com/heroku/java-getting-started
113113
:::>- $ cd java-getting-started
114+
:::-- $ git checkout -t origin/spring-2.0.7
115+
:::-- $ git checkout master
116+
:::-- $ git merge spring-2.0.7
114117
```
115118

116119
You now have a functioning Git repository that contains a simple Java application. The application includes a `pom.xml` file, which is used by Java's dependency manager, Maven.
@@ -132,7 +135,8 @@ By default, Heroku generates a random name (in this case `warm-eyrie-9006`) for
132135
Now deploy your code:
133136

134137
```term
135-
:::>> $ git push heroku master
138+
:::>- $ git push heroku master
139+
:::-> | $ (head -6; echo "..."; tail -18)
136140
```
137141

138142
The application is now deployed. Ensure that at least one instance of the app is running:
@@ -154,23 +158,12 @@ Heroku aggregates all of the output streams from both your app and the platform'
154158
View information about your running app using the `heroku logs --tail` command:
155159

156160
```term
157-
$ heroku logs --tail
158-
2017-04-20T15:06:14.198559+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=43161 -jar target/java-getting-started-1.0.jar`
159-
2017-04-20T15:06:16.478043+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
160-
2017-04-20T15:06:16.484066+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
161-
2017-04-20T15:06:19.396477+00:00 app[web.1]: _ _ _
162-
2017-04-20T15:06:19.396487+00:00 app[web.1]: | | | | | |
163-
2017-04-20T15:06:19.396488+00:00 app[web.1]: | |__| | ___ _ __ ___ | | ___ _
164-
2017-04-20T15:06:19.396489+00:00 app[web.1]: | __ |/ _ \ '__/ _ \| |/ / | | |
165-
2017-04-20T15:06:19.396489+00:00 app[web.1]: | | | | __/ | | (_) | <| |_| |
166-
2017-04-20T15:06:19.396490+00:00 app[web.1]: |_| |_|\___|_| \___/|_|\_\\__,_|
167-
2017-04-20T15:06:19.396491+00:00 app[web.1]:
168-
...
169-
2017-04-20T15:06:33.472964+00:00 app[web.1]: 2017-04-20 15:06:33.472 INFO 4 --- [ main] com.example.Main : Started Main in 15.345 seconds (JVM running for 16.989)
170-
2017-04-20T15:06:33.778990+00:00 heroku[web.1]: State changed from starting to up
171-
```
172-
173-
Visit your application in the browser again to generate another log message.
161+
:::>- background.start("heroku logs --tail", name: "tail", wait: "Tomcat started", timeout: 45)
162+
:::-> | tail -10
163+
:::-- background.stop(name: "tail")
164+
```
165+
166+
Visit your application in the browser again to generate another log message.
174167

175168
Press `CTRL+C` to stop streaming logs.
176169

@@ -180,7 +173,7 @@ Heroku apps use a special plaintext file called the [Procfile](procfile) to expl
180173

181174
The `Procfile` in the example app you deployed looks like this:
182175

183-
```
176+
```yaml
184177
:::-> $ cat Procfile
185178
```
186179

@@ -190,7 +183,7 @@ Procfiles can contain additional process types. For example, you might declare o
190183

191184
<h2 data-next-message="I know how to scale my app">Scale the app</h2>
192185

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`.
186+
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`.
194187

195188
You can check how many dynos are running using the `heroku ps` command:
196189

@@ -200,7 +193,7 @@ You can check how many dynos are running using the `heroku ps` command:
200193

201194
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.
202195

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.
196+
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.
204197

205198
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.
206199

@@ -212,15 +205,15 @@ Scale the number of web dynos to zero:
212205
:::>- $ heroku ps:scale web=0
213206
```
214207

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.
208+
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.
216209

217210
Scale it up again:
218211

219212
```term
220213
:::>- $ heroku ps:scale web=1
221214
```
222215

223-
To prevent abuse, scaling a non-free application to more than one dyno requires [account verification](account-verification).
216+
To prevent abuse, scaling a non-free application to more than one dyno requires [account verification](account-verification).
224217

225218
<h2 data-next-message="I've installed the app dependencies locally">Declare app dependencies</h2>
226219

@@ -243,12 +236,13 @@ Another file, `system.properties`, indicates the version of Java to use (Heroku
243236
Run `mvn clean install` in your local directory to install the dependencies, preparing your system for running the app locally. Note that this app requires Java 8, but you can push your own apps using a different version of Java.
244237

245238
```term
246-
:::>> $ mvn clean install
239+
:::>- $ mvn clean install
240+
:::-> | $ (echo "..."; tail -7)
247241
```
248242

249243
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.
250244

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`.
245+
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`.
252246

253247
If you aren't using Spring in your app, you can accomplish this with the following plugin configuration in the `pom.xml` file.
254248

@@ -272,13 +266,14 @@ Once dependencies are installed, you can run your app locally.
272266
Start your application locally with the `heroku local` CLI command (make sure you've already run `mvn clean install`):
273267

274268
```term
275-
:::>> background.start("heroku local web", name: "local1", wait: "Tomcat started", timeout: 30)
269+
:::>- background.start("heroku local web", name: "local1", wait: "Tomcat started", timeout: 30)
270+
:::-> | $ (echo "..."; tail -4)
276271
:::-- background.stop(name: "local1")
277272
```
278273

279274
Just like the Heroku platform, `heroku local` examines your `Procfile` to determine what command to run.
280275

281-
Open [http://localhost:5000](http://localhost:5000) with your web browser. You should see your app running locally.
276+
Open [http://localhost:5000](http://localhost:5000) with your web browser. You should see your app running locally.
282277

283278
To stop the app from running locally, go back to your terminal window and press `CTRL+C` to exit.
284279

@@ -340,7 +335,8 @@ Now test your changes locally:
340335

341336
```term
342337
:::>- $ mvn clean install
343-
:::>> background.start("heroku local web", name: "local2", wait: "Tomcat started", timeout: 30)
338+
:::>- background.start("heroku local web", name: "local2", wait: "Tomcat started", timeout: 30)
339+
:::-> | $ (echo "..."; tail -4)
344340
:::-- background.stop(name: "local2")
345341
```
346342

@@ -378,8 +374,11 @@ Heroku lets you externalize your app's configuration by storing data such as enc
378374

379375
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:
380376

377+
```
378+
:::-- $ sed -e '56,68d' src/main/java/com/example/Main.java
379+
```
380+
381381
```java
382-
:::-- sed -e '56,68d' src/main/java/com/example/Main.java
383382
:::>> file.append("src/main/java/com/example/Main.java#56")
384383
@RequestMapping("/hello")
385384
String hello(Map<String, Object> model) {
@@ -426,9 +425,8 @@ Deploy your updated application to Heroku to see this in action.
426425
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:
427426

428427
```term
429-
:::-- $ heroku run java -version
430-
:::-- | grep -vq starting
431-
:::-> | grep -vq connecting
428+
:::>- $ heroku run java -version
429+
:::-> | $ tail -4
432430
```
433431

434432
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 +497,7 @@ The example app you deployed already has database functionality, which you can r
499497
The code to access the database is straightforward. Here's the method to insert values into a table called `tick`:
500498

501499
```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
500+
:::-> $ sed -n '45,50p;78,109p' src/main/java/com/example/Main.java
507501
```
508502

509503
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 +523,18 @@ Assuming that you have [Postgres installed locally](heroku-postgresql#local-setu
529523

530524
```term
531525
$ heroku pg:psql
532-
heroku pg:psql
533-
psql (9.3.2, server 9.3.3)
534-
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
526+
psql (10.1, server 9.6.10)
527+
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
535528
Type "help" for help.
536-
=> SELECT * FROM ticks;
529+
530+
DATABASE=> SELECT * FROM ticks;
537531
tick
538532
----------------------------
539-
2014-08-08 14:48:25.155241
540-
2014-08-08 14:51:32.287816
541-
2014-08-08 14:51:52.667683
542-
2014-08-08 14:51:53.1871
543-
2014-08-08 14:51:54.75061
544-
2014-08-08 14:51:55.161848
545-
2014-08-08 14:51:56.197663
546-
2014-08-08 14:51:56.851729
547-
(8 rows)
533+
2018-03-01 20:53:27.148139
534+
2018-03-01 20:53:29.288995
535+
2018-03-01 20:53:29.957118
536+
2018-03-01 21:07:28.880162
537+
(4 rows)
548538
=> \q
549539
```
550540

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>org.springframework.boot</groupId>
1212
<artifactId>spring-boot-starter-parent</artifactId>
13-
<version>2.0.1.RELEASE</version>
13+
<version>2.0.7.RELEASE</version>
1414
<relativePath/>
1515
</parent>
1616
<name>java-getting-started</name>
@@ -19,7 +19,7 @@
1919
<java.version>1.8</java.version>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2121
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22-
<webjars-bootstrap.version>4.1.0</webjars-bootstrap.version>
22+
<webjars-bootstrap.version>4.1.3</webjars-bootstrap.version>
2323
<webjars-jquery-ui.version>1.12.1</webjars-jquery-ui.version>
2424
<webjars-jquery.version>3.3.1-1</webjars-jquery.version>
2525
</properties>

0 commit comments

Comments
 (0)