# pooled-ftp-spring-boot-starter **Repository Path**: Instinctb/pooled-ftp-spring-boot-starter ## Basic Information - **Project Name**: pooled-ftp-spring-boot-starter - **Description**: 一个Ftp连接池的starter,可以集成到Springboot中 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-03-24 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # pooled-ftp-spring-boot-starter > 众所周知,FTP连接每次使用的时候需要建立连接,然后执行业务再销毁连接,但是FTP连接是比较稀缺的资源,这点和JDBC连接比较类似,因此萌生了做一个FTP连接池并集成到Springboot中的项目 ## 使用 首先下载该项目 git clone https://github.com/tydic-kanper/pooled-ftp-spring-boot-starter.git 然后 ``` java mvn install ``` 在需要使用FTP连接池的地方加入Maven依赖 ``` java com.kanper pooled-ftp-spring-boot-starter 1.0 ``` 将项目的jar包安装到本地maven仓库 在项目中只需要在Springboot的yml文件中引入相应的配置,即可完成自动注入 ![pooled-ftp](http://image.kanper.top/pooled-ftp.png "pooled-ftp") ## 核心 ```java @Configuration @ConditionalOnClass(FtpService.class) @EnableConfigurationProperties(FtpConfig.class) public class FtpAutoConfigure { @Autowired private FtpConfig properties; @Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "ftp", value = "enabled", havingValue = "true") public FtpService exampleService() throws Exception { return new FtpService(properties); } } ``` ``` java org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.kanper.conf.FtpAutoConfigure ``` ## 说明 上面的Bean会自动注入到Spring容器;可以在执行业务的地方调用FtpService的方法