# xinjump-framework
**Repository Path**: xinjump/xinjump-framework
## Basic Information
- **Project Name**: xinjump-framework
- **Description**: xinjump系列框架
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 1
- **Created**: 2022-06-09
- **Last Updated**: 2025-09-18
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# xinjump-spring-boot-starter
[](https://central.sonatype.com/artifact/com.gitee.xinjump/xinjump-spring-boot-starter/1.2.2)
[comment]: <> (### Security)
[comment]: <> ([](https://www.murphysec.com/console/report/1672837934137237504/1672837934179180544))
### 介绍
xinjump方便开发,基于常见类进行封装改造,自动注入spring方便使用
### 引入pom
```xml
com.gitee.xinjump
xinjump-spring-boot-starter
1.2.2
```
### 工程使用实例
#### xinjump-base
```text
# BatchFetchExecuteAdaptor
BatchFetchExecuteAdaptor doExecutePartWithoutReturn = new BatchFetchExecuteAdaptor() {
@Override
protected void doExecutePartWithoutReturn(List orgiArgList, Object otherArg) {
System.err.println("处理程序-打印");
}
};
BatchFetchExecuteAdaptor doExecutePage = new BatchFetchExecuteAdaptor() {
@Override
protected List doExecutePage(Integer current, Integer size, Object otherArg) {
if (current == 2) {
return null;
}
return initData();
}
};
BatchFetchExecuteAdaptor doExecutePart = new BatchFetchExecuteAdaptor() {
@Override
protected List doExecutePart(List orgiArgList, Object otherArg) {
if (orgiArgList == null || orgiArgList.isEmpty()) {
return initData();
}
return initData().stream().filter(e -> orgiArgList.contains(e.getUsername())).collect(Collectors.toList());
}
};
BatchFetchExecuteAdaptor doExecuteFull = new BatchFetchExecuteAdaptor() {
@Override
protected List doExecuteFull(Object argList) {
return initData();
}
};
# com.xinjump.base.model.ResponseHelper
# com.xinjump.base.exceptions.BusinessException
# com.xinjump.base.lock.annotation.DistributedLock
@DistributedLock(waitTime = 3, holdTime = 3)
@ApiOperation("锁")
@GetMapping("/lock")
public void lock(@DistributedLockKey @RequestParam(required = false) String key) {
}
# com.xinjump.base.util.*
# com.xinjump.base.validator.group.*
```
#### xinjump-dynamic-datasource
1. 配置多数据源
```yaml
xinjump:
dynamic:
datasource:
test1:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: root
password: root
test2:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: root
password: root
```
2. 指定数据源的两种方式
```text
(1) 通过注解@DS("test1")||@DS("test2")标记要更改的数据源
(2) DynamicDataSourceContextHolder.push("test1")
```
#### xinjump-jsontool
1. 配置指定json(JACKSON,FASTJSON,GSON),默认JACKSON
```yaml
xinjump:
jsontool:
json-type: JACKSON
```
2. 两种使用方式
```text
(1) 通过com.xinjump.jsontool.util.JsonUtil直接调用方法
(2) 注入com.xinjump.jsontool.Json调用其方法
```
#### xinjump-mapstruct
1. 手动读取
```java
@Data
public class User {
private String username;
}
@Data
public class User2 {
private String username;
}
@Mapper
public interface UserMapper extends BeanConvertMapper {
}
public class Main {
public static void main(String[] args) {
User user = new User();
user.setUsername("xinjump");
BeanConvertMappers.config(
MapperConfig.defaultConfig("com.xinjump.mapstruct").build()
);
User2 user2 = BeanConvertMappers.convert(user, User2.class);
}
}
```
2. spring配置mapstruct路径(标记@Mapper)
```yaml
xinjump:
mapstruct:
scan-packages: com.xinjump.mapstruct
User2 user2 = MapstructUtil.convert(user, User2.class);
```
#### xinjump-mybatis-plus
1. crud基础
```java
@RestController
public class UserController extends BaseController {
}
public interface UserService extends IBaseService {
}
@Service
public class UserServiceImpl extends BaseServiceImpl implements UserService {
}
@Mapper
public interface UserMapper extends IBaseMapper {
}
```
2. 全局新增、修改赋值
```yaml
# 设置全局创建时间、修改时间字段名,方便新增、修改时赋值
xinjump:
mybatis-plus:
constant:
create-date: createDate
update-date: updateDate
```
```java
/**
* 默认新增时赋值创建、修改时间
* 默认修改时赋值修改时间
*/
@Component
public class FieldMetaObjectHandler extends BaseMetaObjectHandler {
@Override
public void insertFillOther(MetaObject metaObject) {
// 新增时赋值其他数据
}
@Override
public void updateFillOther(MetaObject metaObject) {
// 修改时赋值其他数据
}
}
```
3. typehandler,类型转换
```text
映射操作
1. mybaits-plus方式
bean上添加注解
@TableName(autoResultMap = true)
映射字段上添加如下注解,指定自定义的handler
# 集合字符串TypeHandler
@TableField(jdbcType = JdbcType.VARCHAR, typeHandler = ListToStringHandler.class)
# 加解密TypeHandler
@TableField(jdbcType = JdbcType.VARCHAR, typeHandler = EncryptTypeHandler.class)
2. mybaits方式
标签内映射字段的handler 指定自定义的handler即可,保存的时候也要指定。
```
#### xinjump-mybatis-plus-generator
1. 配置数据源
```yaml
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/xinjump?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
username: root
password: root
```
2. 定义注释内容
```yaml
#代码生成器,配置信息
mainPath=com.xinjump
#包名
package=com.xinjump.biz
moduleName=
#作者
author=xinjump
#Email
email=xinjump2016@163.com
#版本
version=1.1
```
3. 启动服务
```text
(1)使用postman访问GET http://127.0.0.1:9090/generator/code?tableNames=表名1,表名2 导出
(2)访问http://127.0.0.1:9090 web界面操作
```
#### xinjump-redis
1. 配置redis
```yaml
spring:
redis:
host: 127.0.0.1
port: 6379
database: 0
```
2. 使用
```java
@Component
public class RedisTest {
@Autowired
private RedisService redisService;
@Autowired
private StringRedisService stringRedisService;
// @RedisSelect(4)
public void redisPage() {
stringRedisService.hset("user:1", "username1", "stringRedisService");
Map