Authors: Jan Garong, Yining Wang, Ruo Ning (Nancy) Qiu
Server Setup:
- Run
mvn clean install
to generate a jar file. If this does not work, try running./mvnw clean install
(for MacOS/Linux) ormvnw clean install
on windows. - Run
heroku local web
to run the jar file on the web locally on your computer.
Local PostgreSQL Setup
- Use brew to install PostgreSQL in the terminal:
brew install postgresql
- Once it is installed, enter the command:
brew services start postgresql
- Go to Intellij Database, add a new PostgreSQL Datasource by clicking the
+
sign, it should automatically add the same localhost for you. ClickTest Connection
to ensure it is working. - You must have the PostgreSQL running in the back for test cases to run. To stop it,
enter the command:
brew services stop postgresql
Testing Setup: We are using local PostgreSQL database for testing, ensure you have followed the previous setup.
- For running the main locally, we need to do the following in
java/resources/application.properties
:- Comment out:
spring.datasource.url: ${JDBC_DATABASE_URL:}
- Uncomment:
spring.datasource.url: jdbc:postgresql://localhost:5432/postgres
- Comment out:
- For testing with the heroku database, we need to hardcode with the url by changing
application.properties
correspondingly
Resources used:
- java-get-started by heroku
- RestTemplate Post Request with JSON by baeldung
- Configure Datasource in Spring Boot
- Spring Data JPA Tutorial by Petri Kainulainen
- JUnit Tests for Spring Data JPA by Nam Ha Minh
- Self-Contained Testing Using an In-Memory Database by baeldung
- How to map a PostgreSQL ARRAY to a Java List with JPA and Hibernate by Vlad Mihalcea
- Spring Boot + Session Management Hello World Example - javainuse