基于 tyboot 快速初始化 springboot 单体项目
tyboot源码:
gitee /magintursh/tyboot
github /magintursh/tyboot
示例项目 tybootdemo 源码
tybootdemo /magintursh/tybootdemo
项目目录结构:
其中包名自行定义,;
controller 和 face 目录 为约定目录结构.建议保持一致.
配置文件建议使用多环境配置,启动的时候添加参数 spring.profiles.active 如下:
Run-->Edit Configurations...
pom.xml 文件内容:
tyboot的包放在个人私服,可以临时使用,建议将tyboot源码克隆以后自行打包到自己的私服
<?xml version="1.0" encoding="UTF-8"?>4.0.0org.typroject tybootdemo 1.0jartybootdemotybootdemoUTF-8UTF-81.81.1.20Ty-SNAPSHOTorg.springframework.boot spring-boot-starter-parent 2.1.6.RELEASEorg.typroject tyboot-core-foundation ${tyboot.version}org.typroject tyboot-core-restful ${tyboot.version}org.typroject*org.typroject tyboot-core-auth ${tyboot.version}org.typroject*org.typroject tyboot-core-rdbms ${tyboot.version}org.typroject*org.typroject tyboot-component-cache ${tyboot.version}org.typroject*org.springframework.bootspring-boot-starter-data-redisorg.springframework.boot spring-boot-starter-redis 1.4.5.RELEASEorg.springframework.bootspring-boot-dependencies2.1.6.RELEASEpomimportmaven-publicmaven-public:8081/repository/maven-public/maven-snapshotmaven-snapshot:8081/repository/maven-snapshots/maven-publicmaven-public:8081/repository/maven-public/org.springframework.bootspring-boot-maven-plugin
application.properties 文件内容:
推荐使用多环境配置
spring.application.name=tybootdemoserver.port=30010server.servlet.context-path=/pression.enabled=pression.mime-types=application/json,application/xml,text/html,text/xml,text/plain#默认就是2048 pression.min-response-size=2048#spring.jackson.default-property-inclusion=non_nulllogging.config=classpath:logback-${spring.profiles.active}.xml# mybatis_configmybatis-plus.mapper-locations=classpath:mapper/*Mapper.xmlmybatis-plus.type-aliases-package=org.typroject.*.*.face.*.orm.entity
application-dev.properties 文件内容:
数据库和缓存配置 会接下来演示 示例功能用到.
# jdbc_configspring.datasource.url=jdbc:mysql://192.168.1.212:3306/tybootdemo?characterEncoding=utf8&serverTimezone=Asia/Shanghaispring.datasource.username=tybootdemospring.datasource.password=tybootdemospring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver#not support for spring-boot v1.5+, use org.apache.tomcat.jdbc.pool.DataSource by default.spring.datasource.type=com.zaxxer.hikari.HikariDataSourcespring.datasource.hikari.minimum-idle=5spring.datasource.hikari.maximum-pool-size=15spring.datasource.hikari.auto-commit=truespring.datasource.hikari.idle-timeout=30000spring.datasource.hikari.pool-name=DatebookHikariCPspring.datasource.hikari.max-lifetime=1800000spring.datasource.hikari.connection-timeout=30000spring.datasource.hikari.connection-test-query=SELECT 1# REDIS (RedisProperties)spring.redis.database=10spring.redis.host=192.168.1.212spring.redis.port=6379spring.redis.password=xxxxxspring.redis.timeout=0
logback-dev.xml 文件内容
<?xml version="1.0" encoding="UTF-8"?>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
至此 已经完成工程初始化,可以进一步使用tyboot所有的核心功能,包括
无sql编码体验
基于租户的数据隔离机制
数据缓存
基于简单固定窗口的请求频次限制
基于拦截器的请求拦截扩展
错误处理与异常定义
统一请求上下文
统一返回格式
登录认证方式扩展
认证机制
接口输入输出加密
便捷工具类
本地多账号登录