This commit is contained in:
caozehui
2025-04-01 09:48:17 +08:00
parent 593b7e9d7b
commit 00bda55ddd
6 changed files with 62 additions and 28 deletions

View File

@@ -1,26 +0,0 @@
package com.njcn.gather.system.config;
import cn.hutool.extra.spring.SpringUtil;
import com.njcn.common.bean.CustomCacheUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author caozehui
* @data 2025-03-24
*/
@Configuration
public class CustomCacheConfig {
/**
* 将自定缓存工具类注入到spring容器中
*
* @return
*/
@Bean
public CustomCacheUtil customCacheUtil() {
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
return customCacheUtil;
}
}

View File

@@ -0,0 +1,45 @@
package com.njcn.gather.system.config;
import cn.hutool.extra.spring.SpringUtil;
import com.njcn.common.bean.CustomCacheUtil;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import javax.servlet.MultipartConfigElement;
/**
* @author caozehui
* @data 2025-03-24
*/
@Configuration
public class WebConfig {
/**
* 将自定缓存工具类注入到spring容器中
*
* @return
*/
@Bean
public CustomCacheUtil customCacheUtil() {
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
return customCacheUtil;
}
/**
* 配置上传文件大小限制
*
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个文件最大6MB
factory.setMaxFileSize(DataSize.ofMegabytes(6));
// 整个请求最大12MB
factory.setMaxRequestSize(DataSize.ofMegabytes(12));
return factory.createMultipartConfig();
}
}