feat: 升级0.0.3 完成spring 自动配置模块
This commit is contained in:
parent
d9cffec600
commit
36c8b7d97a
18
README.md
18
README.md
@ -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
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>fluent-sql-spring-jdbc</artifactId>
|
<artifactId>fluent-sql-spring-jdbc</artifactId>
|
||||||
<groupId>group.flyfish.framework</groupId>
|
<groupId>group.flyfish.framework</groupId>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
您只需要注入您的数据源即可自动完成配置。
|
|
||||||
|
然后,您只需要注入您的数据源即可自动完成配置。
|
||||||
|
|
||||||
```java
|
```java
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>fluent-sql</artifactId>
|
<artifactId>fluent-sql</artifactId>
|
||||||
<groupId>group.flyfish.framework</groupId>
|
<groupId>group.flyfish.framework</groupId>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>fluent-sql</artifactId>
|
<artifactId>fluent-sql</artifactId>
|
||||||
<groupId>group.flyfish.framework</groupId>
|
<groupId>group.flyfish.framework</groupId>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
30
fluent-sql-spring-boot-starter/pom.xml
Normal file
30
fluent-sql-spring-boot-starter/pom.xml
Normal 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>
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
|
group.flyfish.fluent.autoconfigure.FluentSqlAutoConfiguration
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>fluent-sql</artifactId>
|
<artifactId>fluent-sql</artifactId>
|
||||||
<groupId>group.flyfish.framework</groupId>
|
<groupId>group.flyfish.framework</groupId>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
14
pom.xml
14
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<groupId>group.flyfish.framework</groupId>
|
<groupId>group.flyfish.framework</groupId>
|
||||||
<artifactId>fluent-sql</artifactId>
|
<artifactId>fluent-sql</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
|
|
||||||
<name>fluent-sql</name>
|
<name>fluent-sql</name>
|
||||||
<description>A very fast sql generation engine using fluent-style api. Help you start your work without mybatis!</description>
|
<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-core</module>
|
||||||
<module>fluent-sql-spring-jdbc</module>
|
<module>fluent-sql-spring-jdbc</module>
|
||||||
<module>fluent-sql-annotations</module>
|
<module>fluent-sql-annotations</module>
|
||||||
|
<module>fluent-sql-spring-boot-starter</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -38,6 +39,7 @@
|
|||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
<lombok.version>1.18.24</lombok.version>
|
<lombok.version>1.18.24</lombok.version>
|
||||||
<jackson.version>2.13.3</jackson.version>
|
<jackson.version>2.13.3</jackson.version>
|
||||||
|
<spring-boot.version>2.7.2</spring-boot.version>
|
||||||
<spring.version>5.3.22</spring.version>
|
<spring.version>5.3.22</spring.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -84,6 +86,11 @@
|
|||||||
<artifactId>fluent-sql-annotations</artifactId>
|
<artifactId>fluent-sql-annotations</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>group.flyfish.framework</groupId>
|
||||||
|
<artifactId>fluent-sql-spring-jdbc</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>group.flyfish.framework</groupId>
|
<groupId>group.flyfish.framework</groupId>
|
||||||
<artifactId>fluent-sql-core</artifactId>
|
<artifactId>fluent-sql-core</artifactId>
|
||||||
@ -94,6 +101,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-jdbc</artifactId>
|
<artifactId>spring-jdbc</artifactId>
|
||||||
|
Loading…
Reference in New Issue
Block a user