一个极为巧合的情况下接触到了JFinal,但是由于本人的技术栈一直以来都是以SpringBoot为主,所以还是希望能够将JFinal集成到SpringBoot中去使用,毕竟Spring的生态还是无比健全的。当前的一些教程,基本都是比较浅的集成方式,SpringBoot与JFinal集成到一起,结果还是各是各的,互不相通,故而此starter的产生。
该项目主要利用SpringBoot的自动配置来将JFinal与SpringBoot深度集成,让SpringBoot与JFinal从此不分彼此。
自制的小工具,欢迎使用和Star,如果使用过程中遇到问题,可以提出Issue,我会尽力完善该工具
- 提供
BeansLoader
注解,可扫描标识类加载Bean,如加载继承了Controller、实现了IPlugin的类到Spring中 - 提供
RouterPath
注解,定义自定义Controller的路由controllerKey - 简化JFinal的数据源,ActiveRecordPlugin默认从Spring加载DataSource
- SpringBoot:2.1.7
- JFinal:4.3
- cron4j:2.2.5
- caffeine:2.6.2
pom.xml
<dependency>
<groupId>com.github.artislong</groupId>
<artifactId>jfinal-spring-boot-starter</artifactId>
<version>1.0</version>
</dependency>
build.gradle
compile 'com.github.artislong:jfinal-spring-boot-starter:1.0'
@BeansLoader(
basePackages = "com.github.artislong",
markerInterfaces = {
Interceptor.class,
Routes.class,
Handler.class,
Render.class
},
annotationClass = RouterPath.class)
@SpringBootApplication
public class JfinalApplication {
public static void main(String[] args) {
SpringApplication.run(JfinalApplication.class, args);
}
}
jfinal:
# 配置数据库方言,不配置时,默认使用MySQL方言
dialect: com.jfinal.plugin.activerecord.dialect.MysqlDialect
# 自动生成的MappingKit,必须配
kit-classes:
- model._MappingKit
# JFinal的SQL模板路径
sql-templates:
- classpath:template/*.sql
# 是否显示SQL
show-sql: true
# 开启跨域配置
origin: true
jfinal:
dev-mode: true
date-pattern: yyyy-MM-dd HH:mm:ss
taskInfoMap:
test01:
cron: '*/5 * * * *'
task: cn.hzsoftware.erp.work.cron.Test01
daemon: true
enable: true
更多配置请查看JfinalProperties
类。
其他常用自定义配置类,可通过JFinal正常开发,如需要增加自定义Interceptor,只需要继承Interceptor,实现自定义逻辑即可。
更多配置请查看SpringJfinalConfiguration
类。