package Ġs ios io . multi pler 2 dbc Ċ Ċ import Ġio . r 2 dbc . pool . Connection Pool Ċ import Ġio . r 2 dbc . pool . Connection Pool Configuration Ċ import Ġio . r 2 dbc . spi . Connection Factories Ċ import Ġio . r 2 dbc . spi . ConnectionFactory Ċ import Ġio . r 2 dbc . spi . ConnectionFactory Options Ċ import Ġorg . springframework . boot . autoconfigure . SpringBoot Application Ċ import Ġorg . springframework . boot . autoconfigure . r 2 dbc . R 2 dbc Properties Ċ import Ġorg . springframework . boot . context . properties . Configuration Properties Ċ import Ġorg . springframework . boot . run Application Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġorg . springframework . data . r 2 dbc . core . R 2 dbc Entity Template Ċ import Ġorg . springframework . data . r 2 dbc . repository . config . Enable R 2 dbc Repositories Ċ import Ġorg . springframework . web . reactive . function . server . co Router Ċ import Ġs ios io . multi pler 2 dbc . db 1 . Db 1 Handler Ċ import Ġs ios io . multi pler 2 dbc . db 2 . Db 2 Handler Ċ Ċ @ SpringBoot Application Ċ class ĠMultiple R 2 dbc Application Ċ Ċ fun Ġmain ( args : ĠArray < String >) Ġ{ ĊĠĠĠ Ġrun Application < Multiple R 2 dbc Application >(* args ) Ċ } Ċ Ċ @ Configuration Ċ class ĠConfig ( ĊĠĠĠ Ġprivate Ġval Ġdb 1 Handler : ĠDb 1 Handler , ĊĠĠĠ Ġprivate Ġval Ġdb 2 Handler : ĠDb 2 Handler Ċ ) Ġ{ ĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġrouter () Ġ= Ġco Router Ġ{ ĊĠĠĠĠĠĠĠ ĠPOST ("/ db 1 ", Ġdb 1 Handler :: post ) ĊĠĠĠĠĠĠĠ ĠPOST ("/ db 2 ", Ġdb 2 Handler :: post ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Configuration Ċ @ Enable R 2 dbc Repositories ( ĊĠĠĠ Ġbase Packages Ġ= Ġ[" si os io . multi pler 2 dbc . db 1 "], ĊĠĠĠ Ġentity Operations Ref Ġ= Ġ" db 1 Entity Template " Ċ ) Ċ class ĠDb 1 Config Ġ{ ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġ@ Configuration Properties ( prefix Ġ= Ġ" db 1 ") ĊĠĠĠ Ġfun Ġdb 1 Properties (): ĠR 2 dbc Properties Ġ= ĠR 2 dbc Properties () ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġdb 1 ConnectionFactory (): ĠConnection Factory Ġ= Ġdb 1 Properties (). to ConnectionFactory () ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġdb 1 Entity Template () Ġ= ĠR 2 dbc Entity Template ( db 1 ConnectionFactory ()) Ċ } Ċ Ċ @ Configuration Ċ @ Enable R 2 dbc Repositories ( ĊĠĠĠ Ġbase Packages Ġ= Ġ[" si os io . multi pler 2 dbc . db 2 "], ĊĠĠĠ Ġentity Operations Ref Ġ= Ġ" db 2 Entity Template " Ċ ) Ċ class ĠDb 2 Config Ġ{ ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġ@ Configuration Properties ( prefix Ġ= Ġ" db 2 ") ĊĠĠĠ Ġfun Ġdb 2 Properties (): ĠR 2 dbc Properties Ġ= ĠR 2 dbc Properties () ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġdb 2 ConnectionFactory (): ĠConnection Factory Ġ= Ġdb 2 Properties (). to ConnectionFactory () ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġdb 2 Entity Template () Ġ= ĠR 2 dbc Entity Template ( db 2 ConnectionFactory ()) Ċ } Ċ Ċ fun ĠR 2 dbc Properties . to ConnectionFactory (): ĠConnection Factory Ġ{ ĊĠĠĠ Ġval Ġconnection Factory Ġ= ĠConnection Factory Options . parse ( url ) ĊĠĠĠĠĠĠĠ Ġ. mutate () ĊĠĠĠĠĠĠĠ Ġ. apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġusername ?. let Ġ{ Ġoption ( ConnectionFactory Options . USER , Ġit ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpassword ?. let Ġ{ Ġoption ( ConnectionFactory Options . PASSWORD , Ġit ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġ}. build (). let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠConnection Factories . get ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġval Ġpool Configuration Ġ= ĠConnection Pool Configuration ĊĠĠĠĠĠĠĠ Ġ. builder ( connection Factory ) ĊĠĠĠĠĠĠĠ Ġ. maxSize ( pool . maxSize ) ĊĠĠĠĠĠĠĠ Ġ. initial Size ( pool . initial Size ) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġreturn ĠConnection Pool ( pool Configuration ) Ċ } Ċ