Skip to content

Commit db41527

Browse files
committed
add persistence module
1 parent 9b5b292 commit db41527

File tree

19 files changed

+41
-21
lines changed

19 files changed

+41
-21
lines changed

springboot-starter-persistence/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
</dependency>
2525

2626
<dependency>
27-
<groupId>com.h2database</groupId>
28-
<artifactId>h2</artifactId>
27+
<groupId>com.mysql</groupId>
28+
<artifactId>mysql-connector-j</artifactId>
2929
<scope>test</scope>
3030
</dependency>
3131

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/AutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codingapi.springboot.persistence;
22

33
import com.codingapi.springboot.persistence.scanner.SchemaScanner;
4-
import com.codingapi.springboot.persistence.schema.SchemaExecutor;
4+
import com.codingapi.springboot.persistence.schema.executor.SchemaExecutor;
55
import com.codingapi.springboot.persistence.schema.SchemaFactory;
66
import org.springframework.beans.factory.annotation.Configurable;
77
import org.springframework.context.annotation.Bean;

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/jdbc/JdbcAutoConfiguration.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.codingapi.springboot.persistence.jdbc;
22

33
import com.codingapi.springboot.persistence.DomainPersistence;
4-
import com.codingapi.springboot.persistence.schema.SchemaExecutor;
4+
import com.codingapi.springboot.persistence.jdbc.executor.JdbcSchemaExecutor;
5+
import com.codingapi.springboot.persistence.jdbc.impl.JdbcDomainPersistence;
6+
import com.codingapi.springboot.persistence.jdbc.impl.JdbcSchemaFactory;
7+
import com.codingapi.springboot.persistence.schema.executor.SchemaExecutor;
58
import com.codingapi.springboot.persistence.schema.SchemaFactory;
69
import org.springframework.beans.factory.annotation.Configurable;
710
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.codingapi.springboot.persistence.jdbc;
1+
package com.codingapi.springboot.persistence.jdbc.executor;
22

33
import com.codingapi.springboot.persistence.schema.Schema;
4-
import com.codingapi.springboot.persistence.schema.SchemaExecutor;
4+
import com.codingapi.springboot.persistence.schema.executor.SchemaExecutor;
55
import lombok.AllArgsConstructor;
66
import org.springframework.jdbc.core.JdbcTemplate;
77
import org.springframework.stereotype.Repository;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codingapi.springboot.persistence.jdbc;
1+
package com.codingapi.springboot.persistence.jdbc.impl;
22

33
import com.codingapi.springboot.persistence.DomainPersistence;
44
import com.codingapi.springboot.persistence.scanner.SchemaContext;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codingapi.springboot.persistence.jdbc;
1+
package com.codingapi.springboot.persistence.jdbc.impl;
22

33
import com.codingapi.springboot.persistence.jdbc.schema.JdbcSchema;
44
import com.codingapi.springboot.persistence.schema.Schema;

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/jdbc/schema/JdbcBuildSchema.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codingapi.springboot.persistence.jdbc.schema;
22

33
import com.codingapi.springboot.persistence.schema.BuildSchema;
4-
import com.codingapi.springboot.persistence.schema.Property;
4+
import com.codingapi.springboot.persistence.property.Property;
55
import com.codingapi.springboot.persistence.schema.Schema;
66

77
import java.util.List;

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/jdbc/schema/JdbcSaveSchema.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.codingapi.springboot.persistence.jdbc.schema;
22

3-
import com.codingapi.springboot.persistence.schema.Property;
3+
import com.codingapi.springboot.persistence.property.Property;
44
import com.codingapi.springboot.persistence.schema.SaveSchema;
55
import com.codingapi.springboot.persistence.schema.Schema;
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codingapi.springboot.persistence.schema;
1+
package com.codingapi.springboot.persistence.property;
22

33
import lombok.extern.slf4j.Slf4j;
44

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codingapi.springboot.persistence.schema;
1+
package com.codingapi.springboot.persistence.property;
22

33
import lombok.Getter;
44
import org.yaml.snakeyaml.introspector.PropertyUtils;

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/scanner/SchemaScanner.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.codingapi.springboot.persistence.register.DomainClassRegister;
44
import com.codingapi.springboot.persistence.schema.Schema;
5-
import com.codingapi.springboot.persistence.schema.SchemaExecutor;
5+
import com.codingapi.springboot.persistence.schema.executor.SchemaExecutor;
66
import com.codingapi.springboot.persistence.schema.SchemaFactory;
77
import lombok.extern.slf4j.Slf4j;
88
import org.springframework.boot.ApplicationArguments;

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/schema/BuildSchema.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.codingapi.springboot.persistence.schema;
22

3+
import com.codingapi.springboot.persistence.property.SchemaProperty;
4+
35
public abstract class BuildSchema {
46

57
public abstract String createSchema();

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/schema/SaveSchema.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.codingapi.springboot.persistence.schema;
22

3+
import com.codingapi.springboot.persistence.property.Property;
4+
import com.codingapi.springboot.persistence.property.SchemaProperty;
35
import lombok.Getter;
46

57
import java.util.ArrayList;

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/schema/Schema.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.codingapi.springboot.persistence.schema;
22

33

4+
import com.codingapi.springboot.persistence.property.SchemaProperty;
45
import lombok.Getter;
56
import lombok.extern.slf4j.Slf4j;
67

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/schema/SchemaExecutor.java

-7
This file was deleted.

springboot-starter-persistence/src/main/java/com/codingapi/springboot/persistence/schema/SearchSchema.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.codingapi.springboot.persistence.schema;
22

3+
import com.codingapi.springboot.persistence.property.SchemaProperty;
34
import lombok.Getter;
45

56
@Getter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.codingapi.springboot.persistence.schema.executor;
2+
3+
import com.codingapi.springboot.persistence.schema.Schema;
4+
5+
public interface SchemaExecutor {
6+
7+
void create(Schema schema);
8+
9+
}

springboot-starter-persistence/src/test/java/com/example/demo/domain/Demo.java

+2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import lombok.Getter;
44
import lombok.Setter;
5+
import lombok.ToString;
56

67
@Setter
78
@Getter
9+
@ToString
810
public class Demo {
911

1012
private int id;
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
codingapi.id.generator.jdbc-url=jdbc:h2:file:./test.db
1+
spring.datasource.url=jdbc:mysql://localhost:3306/demo?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
2+
spring.datasource.username=root
3+
spring.datasource.password=12345678
4+
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
5+
6+
spring.datasource.hikari.maximum-pool-size=1
7+
spring.datasource.hikari.minimum-idle=1
8+
spring.datasource.hikari.connection-timeout=3000

0 commit comments

Comments
 (0)