All Projects → garystafford → Spring Postgresql Demo

garystafford / Spring Postgresql Demo

Licence: apache-2.0
Spring Boot 2.0 application, backed by PostgreSQL, and designed for deployment to Pivotal Cloud Foundry (PCF)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Spring Postgresql Demo

Spring Boot React Oauth2 Social Login Demo
Spring Boot React OAuth2 Social Login with Google, Facebook, and Github
Stars: ✭ 676 (+2839.13%)
Mutual labels:  spring-boot, spring
Mart Holiday Alarm
🛒 마트쉬는날 🏖
Stars: ✭ 22 (-4.35%)
Mutual labels:  spring-boot, spring
Spring Boot Examples
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。
Stars: ✭ 26,812 (+116473.91%)
Mutual labels:  spring-boot, spring
Problem Spring Web
A library for handling Problems in Spring Web MVC
Stars: ✭ 636 (+2665.22%)
Mutual labels:  spring-boot, spring
Journaldev
JournalDev Projects
Stars: ✭ 897 (+3800%)
Mutual labels:  spring-boot, spring
Chaos Monkey Spring Boot
Chaos Monkey for Spring Boot
Stars: ✭ 646 (+2708.7%)
Mutual labels:  spring-boot, spring
Mini Spring
mini-spring是简化版的spring框架,能帮助你快速熟悉spring源码和掌握spring的核心原理。抽取了spring的核心逻辑,代码极度简化,保留spring的核心功能,如IoC和AOP、资源加载器、事件监听器、类型转换、容器扩展点、bean生命周期和作用域、应用上下文等核心功能。
Stars: ✭ 698 (+2934.78%)
Mutual labels:  spring-boot, spring
Spring Testing
A Spring Boot application with lots of sample tests
Stars: ✭ 569 (+2373.91%)
Mutual labels:  spring-boot, spring
Mica
Spring Cloud 微服务开发核心工具集。工具类、验证码、http、redis、ip2region、xss 等,开箱即用。 🔝 🔝 记得右上角点个star 关注更新!
Stars: ✭ 749 (+3156.52%)
Mutual labels:  spring-boot, spring
Go Spring
基于 IoC 的 Go 后端一站式开发框架 🚀
Stars: ✭ 744 (+3134.78%)
Mutual labels:  spring-boot, spring
Febs Shiro
Spring Boot 2.4.2,Shiro1.6.0 & Layui 2.5.6 权限管理系统。预览地址:http://47.104.70.138:8080/login
Stars: ✭ 5,655 (+24486.96%)
Mutual labels:  spring-boot, spring
Localstack Spring Boot
Spring Boot AutoConfiguration for LocalStack
Stars: ✭ 22 (-4.35%)
Mutual labels:  spring-boot, spring
Springboot Starterkit
Starter Kit for Spring Boot based (REST APIs and WebMVC) micro services.
Stars: ✭ 596 (+2491.3%)
Mutual labels:  spring-boot, spring
Retrofit Spring Boot Starter
A springboot starter for retrofit, and supports many functional feature enhancements, greatly simplifying development.(实现了Retrofit与spring-boot框架快速整合,并支持了诸多功能增强,极大简化开发)
Stars: ✭ 658 (+2760.87%)
Mutual labels:  spring-boot, spring
Springfox
Automated JSON API documentation for API's built with Spring
Stars: ✭ 5,449 (+23591.3%)
Mutual labels:  spring-boot, spring
Spring Cloud Consul
Spring Cloud Consul
Stars: ✭ 703 (+2956.52%)
Mutual labels:  spring-boot, spring
Heart First Javaweb
一个走心的 Java Web 入门开发教程
Stars: ✭ 561 (+2339.13%)
Mutual labels:  spring-boot, spring
Spring Cloud Contract
Support for Consumer Driven Contracts in Spring
Stars: ✭ 569 (+2373.91%)
Mutual labels:  spring-boot, spring
Spring Boot Websocket Chat Demo
Spring Boot WebSocket Chat Demo with SockJS fallback and STOMP protocol
Stars: ✭ 726 (+3056.52%)
Mutual labels:  spring-boot, spring
Javaquarkbbs
基于Spring Boot实现的一个简易的Java社区
Stars: ✭ 755 (+3182.61%)
Mutual labels:  spring-boot, spring

License Build Status

Spring Boot 2.0 PostgreSQL Application Demonstration

This project was originally used for the Programmatic Ponderings blog post, Developing Cloud-Native Data-Centric Spring Boot Applications for Pivotal Cloud Foundry, published March, 2018. Spring Boot 2.0 application, backed by PostgreSQL, and designed for deployment to Pivotal Cloud Foundry (PCF). Database changes are handled by Liquibase.

Also, this project was used for the two-part Programmatic Ponderings post, Managing Applications Across Multiple Kubernetes Environments with Istio, published April, 2018.

Docker Quick Start

The project now contains Dockerfile and docker-compose.yml files. If you have Docker and Docker Compose installed locally, you can preview project by creating Docker containers for both the PostgreSQL database and the Spring Boot application. To do so, execute the follow command from the root of the project

git clone --depth 1 --branch master \
  https://github.com/garystafford/spring-postgresql-demo.git
cd spring-postgresql-demo

docker-compose -p springdemo up -d

To follow the startup of the Spring Boot application, use the docker logs springdemo --follow command. When complete, browse to http://localhost:8080. See the list of available resources below.

To delete both Docker containers when done previewing, use the docker rm -f postgres springdemo command.

Build and Run Application with Gradle

The project assumes you have Docker and the Cloud Foundry Command Line Interface (cf CLI) installed locally.

First, provision the local PostgreSQL development database using Docker:

# create container
docker run --name postgres \
  -e POSTGRES_USERNAME=postgres \
  -e POSTGRES_PASSWORD=postgres1234 \
  -e POSTGRES_DB=elections \
  -p 5432:5432 \
  -d postgres

# view container
docker container ls

# trail container logs
docker logs postgres  --follow

Local database connection details are set in the src\main\resources\application.yml file.

The default Spring Profile, uses an h2 instance:

datasource:
  url: jdbc:h2:mem:elections
  username: sa
  password:
  driver-class-name: org.h2.Driver
  jpa:
    show-sql: true
h2:
  console:
    enabled: true

The dev Spring Profile, uses localhost PostgreSQL instance:

datasource:
  url: jdbc:postgresql://localhost:5432/elections
  username: postgres
  password: postgres1234
  driver-class-name: org.postgresql.Driver
jpa:
  show-sql: true

Optionally, you can override any of the setting in the src\main\resources\application.yml files, by setting local environment variables, such as:

# use 'set' on Windows
export SPRING_PROFILES_ACTIVE=<profile>
export SPRING_DATASOURCE_URL=<some_other_url>
export SPRING_DATASOURCE_USERNAME=<some_other_username>
export SPRING_DATASOURCE_PASSWORD=<some_other_password>

Next, build and run service locally, using Gradle, against the local Docker PostgreSQL database instance. This command will also execute the Liquibase change sets on the Docker PostgreSQL elections database.

SPRING_PROFILES_ACTIVE=dev ./gradlew clean bootRun

To view Liquibase database changelog:

SELECT * FROM databasechangelog;

To delete the local Docker-based PostgreSQL database:

docker rm -f postgres

Deploy to Pivotal Web Services

Purchase and provision an ElephantSQL PostgreSQL as a Service instance through the Pivotal Services Marketplace. Note the 'panda' service plan is NOT FREE! To purchase, you must have a Pivotal account with a credit card attached.

# view elephantsql service plans
cf marketplace -s elephantsql

# purchase elephantsql service plan
cf create-service elephantsql panda elections

# display details of running service
cf service elections

Deploy the Spring Boot service to Pivotal Web Services.

gradle build && cf push

Scale up instances:

# scale up to 2 instances
cf scale cf-spring -i 2

# review status of both instances
cf app pcf-postgresql-demo

Available Resources

Below is a partial list of the application's exposed resources. To see all resources, use the /actuator/mappings resource.

  • Actuator

    • /
    • /actuator/mappings (shows all resources!)
    • /actuator/metrics
    • /actuator/metrics/{metric}
    • /actuator/liquibase
    • /actuator/env
    • /actuator/configprops
    • /actuator/health
    • /actuator/info
    • /actuator/beans
  • Swagger

    • /swagger-ui.html
    • /v2/api-docs
  • h2 (default Spring Profile only)

    • /h2-console
  • Candidates (DB Table)

    • /candidates
    • /candidates/{id}
    • /profile/candidates
    • /candidates/search
    • /candidates/search/findByLastName?lastName=Obama
    • /candidates/search/findByPoliticalParty?politicalParty=Democratic%20Party
    • /candidates/summary
    • /candidates/summary/{politicalParty}
  • Elections (DB Table)

    • /elections
    • /elections/{id}
    • /profile/elections
    • /elections/search
    • /elections/search/findByTitle?title=2012%20Presidential%20Election
    • /elections/search/findByDescriptionContains?description=American
    • /elections/summary
  • Votes (DB Table)

    • /votes
    • /votes/{is}
    • /votes?page={page}}&size={size}
    • /profile/votes
  • Election Candidates (DB Table)

    • /electionCandidates
    • /profile/electionCandidates
  • Candidates, by Elections (DB View)

    • /election-candidates (GET only)
    • /profile/election-candidates
    • /election-candidates/search/findByElection?election=2016%20Presidential%20Election
  • Individual Votes, by Election (DB View)

    • /election-votes (GET only)
    • /election-votes?page={page}}&size={size} (GET only)
    • /profile/election-votes
    • /election-votes/search/findByElection?election=2012%20Presidential%20Election
    • /election-votes/summary
    • /election-votes/summary/{election}
  • Total Votes by Election and by Candidate (DB View)

    • /vote-totals (GET only)
    • /profile/vote-totals
    • /vote-totals/search/findByElection?election=2012%20Presidential%20Election
    • /election-votes/summary

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].