Permalink
Browse files

Sync with devcenter

  • Loading branch information...
1 parent 06456ad commit 72ee062f17569d507cadca1c485bf433f97a6493 @naaman naaman committed Sep 6, 2012
Showing with 27 additions and 15 deletions.
  1. +27 −15 README.md
View
@@ -1,17 +1,18 @@
-This guide will show you how to deploy a Spring MVC Hibernate application to Heroku and bind it to the free Postgres database service.
+This quickstart will get you going with a Spring MVC Hibernate application that uses a Postgres database service, deployed to Heroku.
-Sample code is available on [github](https://github.com/heroku/devcenter-spring-mvc-hibernate) along with this document. Edits and enhancements are welcome. Just fork the repository, make your changes and send us a pull request.
+{.note}
+Sample code for the [demo application](https://github.com/heroku/devcenter-spring-mvc-hibernate) is available on GitHub. Edits and enhancements are welcome. Just fork the repository, make your changes and send us a pull request.
## Prerequisites
-* Java, Maven, Git, and the Heroku client (as described in the [basic Java quickstart](/java))
+* Java, Maven, Git, and the Heroku client (as described in the [basic Java quickstart](java))
* An installed version of [Postgres](http://www.postgresql.org/) to test locally
-## Create a Java App That Uses Spring MVC and Hibernate
+## Create a Java app that uses Spring MVC and Hibernate
If you don't already have a Spring MVC Hibernate app, the easiest way to create one is with Spring Roo. Spring Roo is a RAD tool that lets you quickly build Spring MVC applications with a complete model, view and controller layer, including relational database integration.
-### Option 1. Clone the Sample App
+### Option 1. Clone the sample app
If you don't want to install Spring Roo, you can clone the sample app:
@@ -31,7 +32,7 @@ This will check out the completed app. To step back to the starting point, do:
Now you can skip forward to "Modify Database Configuration".
-### Option 2. Create the App Using Spring Roo
+### Option 2. Create the app using Spring Roo
[Install Spring Roo](http://www.springsource.com/download/community?project=Spring%20Roo) if you don't already have it. Then create a directory for your app and generate the app using the `clinic.roo` script:
@@ -74,13 +75,13 @@ Finally, let's create a git repo and commit this baseline of our application:
$ git add .
$ git commit -m init
-## Modify Database Configuration
+## Modify database configuration
The web app generated by Spring Roo expects you to set database connection properties in the file `src/main/resources/META-INF/spring/database.properties`. However, it is not a good idea to hardcode database configuration into a file that is part of your project. Instead, we will edit the Spring configuration to read the configuration from an environment variable.
Heroku automatically provisions a small database when you create a Java application and sets the `DATABASE_URL` environment variable to a URL of the format
- postgres://user:password@hostname/path
+ postgres://user:password@hostname:port/dbname
You can also provision a larger database service yourself using the `heroku addons` command. Either way, the database connection information will be stored in the `DATABASE_URL` variable.
@@ -133,18 +134,28 @@ Jetty Runner lets you easily execute your web app as a standard Java application
</executions>
</plugin>
-## Declare Process Types in a Procfile
+## Declare process types with Procfile
You declare how you want your application executed in `Procfile` in the project root. Create this file with a single line:
:::term
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
-## Run Your App Locally
+## Optionally Choose a JDK
+By default, OpenJDK 1.6 is installed with your app. However, you can choose to use a newer JDK by specifying `java.runtime.version=1.7` in the `system.properties` file.
+
+Here's what a `system.properties` file looks like:
+
+ :::term
+ java.runtime.version=1.7
+
+You can specify 1.6, 1.7, or 1.8 (1.8 is in beta) for Java 6, 7, or 8 (with lambdas), respectively.
+
+## Run your app locally
Let's run the app locally first to test that it all works. You must have a Postgres database up and running and accessible on the `DATABASE_URL` you specified above.
-### Build Your App
+### Build your app
:::term
$ mvn package
@@ -166,7 +177,7 @@ Let's run the app locally first to test that it all works. You must have a Postg
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
-### Start Your App
+### Start your app
<div class="callout" markdown="1">
Note: you can also start your app using foreman to execute the Procfile. [Read more about foreman and procfiles](http://devcenter.heroku.com/articles/procfile).
@@ -179,25 +190,26 @@ Note: you can also start your app using foreman to execute the Procfile. [Read m
Go to <http://localhost:8080> and test it out by creating a new record.
-## Deploy to Heroku/Cedar
+## Deploy to Heroku
Commit your changes to Git:
:::term
$ git add .
$ git commit -m "Ready to deploy"
-Create the app on the Cedar stack:
+Create the app:
:::term
- $ heroku create --stack cedar
+ $ heroku create
Creating high-lightning-129... done, stack is cedar
http://high-lightning-129.herokuapp.com/ | git@heroku.com:high-lightning-129.git
Git remote heroku added
Deploy your code:
:::term
+ $ git push heroku master
Counting objects: 227, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (117/117), done.

0 comments on commit 72ee062

Please sign in to comment.