File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Spring_part_7/src/main/java/spring/oldboy/config Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ package spring .oldboy .config ;
2+
3+ import org .springframework .beans .factory .annotation .Value ;
4+ import org .springframework .beans .factory .config .BeanDefinition ;
5+ import org .springframework .context .annotation .*;
6+ import spring .oldboy .pool .ConnectionPool ;
7+ import spring .oldboy .repository .UserRepository ;
8+
9+ @ Configuration
10+ public class ApplicationConfiguration {
11+
12+ @ Bean ("pool2" )
13+ @ Scope (BeanDefinition .SCOPE_SINGLETON )
14+ public ConnectionPool pool2 (@ Value ("${db.username}" ) String username ) {
15+ return new ConnectionPool (username , 20 );
16+ }
17+
18+ @ Bean
19+ public ConnectionPool pool3 () {
20+ return new ConnectionPool ("test-pool" , 25 );
21+ }
22+
23+ @ Bean
24+ public UserRepository userRepository2 (ConnectionPool pool2 ) {
25+ return new UserRepository (pool2 );
26+ }
27+
28+ @ Bean
29+ public UserRepository userRepository3 () {
30+ return new UserRepository (pool3 ());
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments