Skip to content

Commit a43edf4

Browse files
committed
mybatis change to jpa
1 parent 4e900e9 commit a43edf4

34 files changed

+324
-318
lines changed

leaf-server/pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
</dependency>
4141

4242
<dependency>
43-
<groupId>org.mybatis</groupId>
44-
<artifactId>mybatis</artifactId>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-data-jpa</artifactId>
4545
</dependency>
4646

4747
<dependency>
@@ -54,11 +54,6 @@
5454
<artifactId>spring-boot-starter-web</artifactId>
5555
</dependency>
5656

57-
<dependency>
58-
<groupId>com.alibaba</groupId>
59-
<artifactId>druid</artifactId>
60-
</dependency>
61-
6257
<dependency>
6358
<groupId>mysql</groupId>
6459
<artifactId>mysql-connector-java</artifactId>

leaf-server/src/main/java/com/sankuai/inf/leaf/IDGen.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

leaf-server/src/main/java/com/sankuai/inf/leaf/segment/dao/IDAllocMapper.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

leaf-server/src/main/java/com/sankuai/inf/leaf/segment/dao/impl/IDAllocDaoImpl.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

leaf-server/src/main/java/com/sankuai/inf/leaf/segment/model/LeafAlloc.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

leaf-server/src/main/java/com/sankuai/inf/leaf/server/Constants.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
public class Constants {
44

55
public static final String LEAF_SEGMENT_ENABLE = "leaf.segment.enable";
6-
public static final String LEAF_JDBC_URL = "leaf.jdbc.url";
7-
public static final String LEAF_JDBC_USERNAME = "leaf.jdbc.username";
8-
public static final String LEAF_JDBC_PASSWORD = "leaf.jdbc.password";
9-
public static final String LEAF_JDBC_DRIVER = "leaf.jdbc.driver";
10-
116
public static final String LEAF_SNOWFLAKE_ENABLE = "leaf.snowflake.enable";
12-
public static final String LEAF_SNOWFLAKE_PORT = "leaf.snowflake.port";
13-
public static final String LEAF_SNOWFLAKE_ZK_ADDRESS = "leaf.snowflake.zk.address";
147

158
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.sankuai.inf.leaf.server;
2+
3+
import com.sankuai.inf.leaf.server.common.Result;
4+
5+
public interface IDGen {
6+
7+
Result get(String key);
8+
9+
boolean init();
10+
11+
}
Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
11
package com.sankuai.inf.leaf.server;
22

3+
import com.sankuai.inf.leaf.server.properties.LeafProperties;
4+
import com.zaxxer.hikari.HikariConfig;
5+
import com.zaxxer.hikari.HikariDataSource;
36
import org.springframework.boot.SpringApplication;
47
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
59
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
10+
import org.springframework.boot.context.properties.ConfigurationProperties;
11+
import org.springframework.context.annotation.Bean;
12+
import org.springframework.context.annotation.Configuration;
613

7-
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
14+
import javax.sql.DataSource;
15+
16+
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
817
public class LeafServerApplication {
918

1019
public static void main(String[] args) {
1120
SpringApplication.run(LeafServerApplication.class, args);
1221
}
22+
23+
24+
@Bean
25+
@ConfigurationProperties(prefix = "leaf.snowflake")
26+
public LeafProperties leafProperties(){
27+
return new LeafProperties();
28+
}
29+
30+
@Configuration
31+
@ConditionalOnProperty(name = Constants.LEAF_SEGMENT_ENABLE,havingValue = "true")
32+
static class JpaDataSourceConfiguration{
33+
34+
@Bean
35+
@ConfigurationProperties(prefix = "spring.datasource")
36+
public HikariConfig hikariConfig(){
37+
return new HikariConfig();
38+
}
39+
40+
@Bean
41+
public DataSource dataSource(HikariConfig hikariConfig){
42+
return new HikariDataSource(hikariConfig);
43+
}
44+
}
45+
46+
1347
}

leaf-server/src/main/java/com/sankuai/inf/leaf/common/CheckVO.java renamed to leaf-server/src/main/java/com/sankuai/inf/leaf/server/common/CheckVO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sankuai.inf.leaf.common;
1+
package com.sankuai.inf.leaf.server.common;
22

33
import lombok.AllArgsConstructor;
44
import lombok.Getter;

leaf-server/src/main/java/com/sankuai/inf/leaf/common/PropertyFactory.java renamed to leaf-server/src/main/java/com/sankuai/inf/leaf/server/common/PropertyFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sankuai.inf.leaf.common;
1+
package com.sankuai.inf.leaf.server.common;
22

33
import lombok.extern.slf4j.Slf4j;
44

0 commit comments

Comments
 (0)