feat: 升级0.0.3 完成spring 自动配置模块

This commit is contained in:
wangyu 2022-09-07 14:30:14 +08:00
parent d9cffec600
commit 36c8b7d97a
8 changed files with 96 additions and 7 deletions

View File

@ -14,15 +14,27 @@
## 快速接入使用
如果您的项目使用maven并且使用spring-jdbc可通过以下配置快速集成
### SpringBoot
如果您的项目使用maven并且使用spring-boot可通过以下配置快速集成
```xml
<dependency>
<artifactId>fluent-sql-spring-boot-starter</artifactId>
<groupId>group.flyfish.framework</groupId>
<version>0.0.3</version>
</dependency>
```
### Spring MVC
没有使用spring boot也没关系如果项目使用spring请只依赖它
```xml
<dependency>
<artifactId>fluent-sql-spring-jdbc</artifactId>
<groupId>group.flyfish.framework</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</dependency>
```
您只需要注入您的数据源即可自动完成配置。
然后,您只需要注入您的数据源即可自动完成配置。
```java
import javax.sql.DataSource;

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId>
<version>0.0.3</version>
</parent>
<description>spring boot 快速集成组件</description>
<modelVersion>4.0.0</modelVersion>
<artifactId>fluent-sql-spring-boot-starter</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>group.flyfish.framework</groupId>
<artifactId>fluent-sql-spring-jdbc</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,33 @@
package group.flyfish.fluent.autoconfigure;
import group.flyfish.fluent.operations.FluentSQLOperations;
import group.flyfish.fluent.operations.JdbcTemplateFluentSQLOperations;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
/**
* fluent sql自动配置
*
* @author wangyu
*/
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
public class FluentSqlAutoConfiguration {
/**
* 动态注入初始化的bean完成注入配置
*
* @param dataSource 从spring datasource注入
*/
@Bean
@ConditionalOnMissingBean(FluentSQLOperations.class)
@ConditionalOnBean(DataSource.class)
public FluentSQLOperations fluentSQLOperations(DataSource dataSource) {
return new JdbcTemplateFluentSQLOperations(new JdbcTemplate(dataSource));
}
}

View File

@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
group.flyfish.fluent.autoconfigure.FluentSqlAutoConfiguration

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId>
<version>0.0.2</version>
<version>0.0.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

14
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>group.flyfish.framework</groupId>
<artifactId>fluent-sql</artifactId>
<packaging>pom</packaging>
<version>0.0.2</version>
<version>0.0.3</version>
<name>fluent-sql</name>
<description>A very fast sql generation engine using fluent-style api. Help you start your work without mybatis</description>
@ -31,6 +31,7 @@
<module>fluent-sql-core</module>
<module>fluent-sql-spring-jdbc</module>
<module>fluent-sql-annotations</module>
<module>fluent-sql-spring-boot-starter</module>
</modules>
<properties>
@ -38,6 +39,7 @@
<maven.compiler.target>8</maven.compiler.target>
<lombok.version>1.18.24</lombok.version>
<jackson.version>2.13.3</jackson.version>
<spring-boot.version>2.7.2</spring-boot.version>
<spring.version>5.3.22</spring.version>
</properties>
@ -84,6 +86,11 @@
<artifactId>fluent-sql-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>group.flyfish.framework</groupId>
<artifactId>fluent-sql-spring-jdbc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>group.flyfish.framework</groupId>
<artifactId>fluent-sql-core</artifactId>
@ -94,6 +101,11 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>