Skip to content

Commit c546892

Browse files
committed
Add ApplicationConfiguration.java
1 parent 4864515 commit c546892

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)