Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Demo for spring boot read write splitting

License

NotificationsYou must be signed in to change notification settings

Vipcube/Demo-SpringBoot-DB-ReadWriteSplitting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup Database Replication with Docker

Startup the Database.

docker-compose up -d

Setup Database Replication Role

  • Access the psql client
psql -U postgres
  • Create the user 'reading_user' and giving him permissions
CREATE USER reading_user WITH PASSWORD'reading_pass';GRANT CONNECT ON DATABASE my_database TO reading_user;GRANT SELECT ON ALL TABLES IN SCHEMA public TO reading_user;GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO reading_user;GRANT USAGE ON SCHEMA public TO reading_user;ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO reading_user;

Startup Database Proxy

docker-compose up -d -f docker-compose-proxy.yml

Run the Spring Boot Application

Native Datasource mode

mvn spring-boot:run -Dspring-boot.run.profiles=direct

Database Proxy mode

mvn spring-boot:run -Dspring-boot.run.profiles=proxy

Test with API

Create a new user

curl --location'http://localhost:8080/api/app-user' \--header'Content-Type: application/json' \--data'{        "name": "test4"    }'

Get all users

curl --location'http://localhost:8080/api/app-user'

About

Demo for spring boot read write splitting

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp