File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
springboot-starter-leaf/src/main/java/com/codingapi/springboot/leaf Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 11package com .codingapi .springboot .leaf ;
22
3+ import com .codingapi .springboot .leaf .properties .LeafProperties ;
34import com .sankuai .inf .leaf .IDGen ;
45import com .sankuai .inf .leaf .segment .SegmentIDGenImpl ;
56import com .sankuai .inf .leaf .segment .dao .IDAllocDao ;
67import com .sankuai .inf .leaf .segment .dao .impl .IDAllocDaoImpl ;
7- import org .springframework .boot .autoconfigure . condition . ConditionalOnMissingBean ;
8+ import org .springframework .boot .context . properties . ConfigurationProperties ;
89import org .springframework .context .annotation .Bean ;
910import org .springframework .context .annotation .Configuration ;
1011
1112@ Configuration
1213public class AutoConfiguration {
1314
1415 @ Bean
15- @ ConditionalOnMissingBean
16- public IDAllocDao allocDao (){
17- return new IDAllocDaoImpl ("jdbc:h2:mem:leaf;DB_CLOSE_DELAY=-1" );
16+ @ ConfigurationProperties (prefix = "codingapi.leaf" )
17+ public LeafProperties leafProperties (){
18+ return new LeafProperties ();
19+ }
20+
21+ @ Bean
22+ public IDAllocDao allocDao (LeafProperties leafProperties ){
23+ return new IDAllocDaoImpl (leafProperties .getJdbcUrl ());
1824 }
1925
2026
Original file line number Diff line number Diff line change 1+ package com .codingapi .springboot .leaf .properties ;
2+
3+ import lombok .Getter ;
4+ import lombok .Setter ;
5+
6+ @ Setter
7+ @ Getter
8+ public class LeafProperties {
9+
10+ private String jdbcUrl = "jdbc:h2:mem:leaf;DB_CLOSE_DELAY=-1" ;
11+
12+ }
You can’t perform that action at this time.
0 commit comments