|
|
5 years ago | |
|---|---|---|
| .mvn/wrapper | 5 years ago | |
| src/main | 5 years ago | |
| .gitignore | 5 years ago | |
| Procfile | 5 years ago | |
| README.md | 5 years ago | |
| mvnw | 5 years ago | |
| mvnw.cmd | 5 years ago | |
| pom.xml | 5 years ago | |
| system.properties | 5 years ago | |
README.md
Steps to Create and Deploy:
set up local
local postgres
- open your postgres app and start the db server
- in the postgres app, double click one of the existing databases to enter
psql - once inside
psql, runCREATE DATABASE springreactapp;
in your browser
- fork this repo
in your terminal
- clone your fork of this repo onto your local computer somewhere outside the class repo
cdinto the local repo- Run
java --version. Note, this may open a prompt you to install Java: click "More Info" and follow installation instructions. Once complete, rerun the previous command - The first line that this command gives you is the version of Java and the date of its release (e.g.
java 15 2020-09-15tells you it is Java version 15) - Now open the
system.propertiesfile that is at the root of this project. Make sure the number next tojava.runtime.versionin thesystem.propertiesfile in your repo matches your version of Java. Egjava.runtime.version=15is the correct version for the above output from terminal. If not, change that line of code to the correct number from terminal. Then git add/commit/push
Set up an environment variable so your local spring app will use your local postgres database. In terminal:
export JDBC_DATABASE_URL=jdbc:postgresql://localhost:5432/contacts
Important - make sure you have a database named contacts, if you are using another database, be sure to change the last part of the url from contacts to the name of the database you want to use
Now start spring:
./mvnw spring-boot:run
in your browser
go to http://localhost:8080/ to view local app (note this uses your local postgres database)
set up heroku
in your terminal
- run
heroku create(take note of the app name for later)
in your browser
- go to heroku.com in your browser and sign in
- find this newly created heroku app in your list of available apps and click on it
- go to resources
- search for postgres and choose Heroku Postgres
- choose "Hobby Dev - Free"
- click provision
in your terminal
in your terminal
-
if running
psqlgives you "command not found", runln -s /Applications/Postgres.app/Contents/Versions/latest/bin/psql /usr/local/bin/psql -
run
heroku pg:psql -
once inside heroku's psql, run
CREATE TABLE people (id SERIAL, name VARCHAR(16), age INT);INSERT INTO people ( name, age ) VALUES ( 'Matt', 38 );INSERT INTO people ( name, age ) VALUES ( 'Sally', 54 );INSERT INTO people ( name, age ) VALUES ( 'Zanthar', 4892 );
-
exit heroku psql with
\q -
run
git push heroku master -
run
heroku opento see app (note this uses your heroku postgres database, which will have different data than your local db) -
run
git push heroku master -
run
heroku opento see app (note this uses your heroku postgres database, which will have different data than your local db)
Rerunning local after initial set up
Open Postgres app and start the db
In terminal:
- Go to repo root dir
- Run
export JDBC_DATABASE_URL=jdbc:postgresql://localhost:5432/contactsagain - Run
./mvnw spring-boot:run
In Browser go to http://localhost:8080/