---author:scott---date:2023-05-10---for:yml属性为空导致项目启动报错,改造后支持单体非system独立启动---

pull/4938/head
zhangdaiscott 2023-05-10 17:13:44 +08:00
parent 545679f999
commit ba40a797df
10 changed files with 66 additions and 15 deletions

View File

@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.util.RestUtil; import org.jeecg.common.util.RestUtil;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -22,6 +23,7 @@ import java.util.*;
*/ */
@Slf4j @Slf4j
@Component @Component
@ConditionalOnProperty(prefix = "jeecg.elasticsearch", name = "cluster-nodes")
public class JeecgElasticsearchTemplate { public class JeecgElasticsearchTemplate {
/** es服务地址 */ /** es服务地址 */
private String baseUrl; private String baseUrl;

View File

@ -11,6 +11,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.JeecgBaseConfig;
import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ExportParams;
@ -23,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@ -40,9 +42,9 @@ public class JeecgController<T, S extends IService<T>> {
/**issues/2933 JeecgController注入service时改用protected修饰能避免重复引用service*/ /**issues/2933 JeecgController注入service时改用protected修饰能避免重复引用service*/
@Autowired @Autowired
protected S service; protected S service;
@Resource
@Value("${jeecg.path.upload}") private JeecgBaseConfig jeecgBaseConfig;
private String upLoadPath;
/** /**
* excel * excel
* *
@ -69,7 +71,7 @@ public class JeecgController<T, S extends IService<T>> {
mv.addObject(NormalExcelConstants.CLASS, clazz); mv.addObject(NormalExcelConstants.CLASS, clazz);
//update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置-------------------- //update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
exportParams.setImageBasePath(upLoadPath); exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置---------------------- //update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams); mv.addObject(NormalExcelConstants.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList); mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
@ -108,7 +110,7 @@ public class JeecgController<T, S extends IService<T>> {
IPage<T> pageList = service.page(page, queryWrapper); IPage<T> pageList = service.page(page, queryWrapper);
List<T> exportList = pageList.getRecords(); List<T> exportList = pageList.getRecords();
Map<String, Object> map = new HashMap<>(5); Map<String, Object> map = new HashMap<>(5);
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i,upLoadPath); ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i,jeecgBaseConfig.getPath().getUpload());
exportParams.setType(ExcelType.XSSF); exportParams.setType(ExcelType.XSSF);
//map.put("title",exportParams); //map.put("title",exportParams);
//表格Title //表格Title

View File

@ -62,6 +62,8 @@ public class DySmsHelper {
//update-begin-authortaoyan date:20200811 for:配置类数据获取 //update-begin-authortaoyan date:20200811 for:配置类数据获取
StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class); StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
logger.info("阿里大鱼短信秘钥 accessKeyId" + staticConfig.getAccessKeyId());
logger.info("阿里大鱼短信秘钥 accessKeySecret"+ staticConfig.getAccessKeySecret());
setAccessKeyId(staticConfig.getAccessKeyId()); setAccessKeyId(staticConfig.getAccessKeyId());
setAccessKeySecret(staticConfig.getAccessKeySecret()); setAccessKeySecret(staticConfig.getAccessKeySecret());
//update-end-authortaoyan date:20200811 for:配置类数据获取 //update-end-authortaoyan date:20200811 for:配置类数据获取

View File

@ -21,7 +21,7 @@ public class PmsUtil {
private static String uploadPath; private static String uploadPath;
@Value("${jeecg.path.upload}") @Value("${jeecg.path.upload:}")
public void setUploadPath(String uploadPath) { public void setUploadPath(String uploadPath) {
PmsUtil.uploadPath = uploadPath; PmsUtil.uploadPath = uploadPath;
} }

View File

@ -1,6 +1,7 @@
package org.jeecg.config; package org.jeecg.config;
import org.jeecg.config.vo.DomainUrl; import org.jeecg.config.vo.DomainUrl;
import org.jeecg.config.vo.Elasticsearch;
import org.jeecg.config.vo.Path; import org.jeecg.config.vo.Path;
import org.jeecg.config.vo.Shiro; import org.jeecg.config.vo.Shiro;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
@ -52,6 +53,18 @@ public class JeecgBaseConfig {
* *
*/ */
private String fileViewDomain; private String fileViewDomain;
/**
* ES
*/
private Elasticsearch elasticsearch;
public Elasticsearch getElasticsearch() {
return elasticsearch;
}
public void setElasticsearch(Elasticsearch elasticsearch) {
this.elasticsearch = elasticsearch;
}
public Boolean getSafeMode() { public Boolean getSafeMode() {
return safeMode; return safeMode;

View File

@ -12,13 +12,13 @@ import org.springframework.stereotype.Component;
@Data @Data
public class StaticConfig { public class StaticConfig {
@Value("${jeecg.oss.accessKey}") @Value("${jeecg.oss.accessKey:}")
private String accessKeyId; private String accessKeyId;
@Value("${jeecg.oss.secretKey}") @Value("${jeecg.oss.secretKey:}")
private String accessKeySecret; private String accessKeySecret;
@Value(value = "${spring.mail.username}") @Value(value = "${spring.mail.username:}")
private String emailFrom; private String emailFrom;
// /** // /**

View File

@ -25,6 +25,7 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter; import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -59,12 +60,13 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
*/ */
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**") ResourceHandlerRegistration resourceHandlerRegistration = registry.addResourceHandler("/**");
//update-begin-author:taoyan date:20211116 for: jeecg.path.webapp配置无效 #3126 if (jeecgBaseConfig.getPath() != null && jeecgBaseConfig.getPath().getUpload() != null) {
.addResourceLocations("file:" + jeecgBaseConfig.getPath().getUpload() + "//") resourceHandlerRegistration
.addResourceLocations("file:" + jeecgBaseConfig.getPath().getWebapp() + "//") .addResourceLocations("file:" + jeecgBaseConfig.getPath().getUpload() + "//")
//update-end-author:taoyan date:20211116 for: jeecg.path.webapp配置无效 #3126 .addResourceLocations("file:" + jeecgBaseConfig.getPath().getWebapp() + "//");
.addResourceLocations(staticLocations.split(",")); }
resourceHandlerRegistration.addResourceLocations(staticLocations.split(","));
} }
/** /**

View File

@ -5,6 +5,7 @@ import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.util.MinioUtil; import org.jeecg.common.util.MinioUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -14,6 +15,7 @@ import org.springframework.context.annotation.Configuration;
*/ */
@Slf4j @Slf4j
@Configuration @Configuration
@ConditionalOnProperty(prefix = "jeecg.minio.minio", name = "minio_url")
public class MinioConfig { public class MinioConfig {
@Value(value = "${jeecg.minio.minio_url}") @Value(value = "${jeecg.minio.minio_url}")
private String minioUrl; private String minioUrl;

View File

@ -2,6 +2,7 @@ package org.jeecg.config.oss;
import org.jeecg.common.util.oss.OssBootUtil; import org.jeecg.common.util.oss.OssBootUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -10,6 +11,7 @@ import org.springframework.context.annotation.Configuration;
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Configuration @Configuration
@ConditionalOnProperty(prefix = "jeecg.oss", name = "endpoint")
public class OssConfiguration { public class OssConfiguration {
@Value("${jeecg.oss.endpoint}") @Value("${jeecg.oss.endpoint}")

View File

@ -0,0 +1,26 @@
package org.jeecg.config.vo;
/**
* @author: scott
* @date: 20230510 16:06
*/
public class Elasticsearch {
private String clusterNodes;
private boolean checkEnabled;
public String getClusterNodes() {
return clusterNodes;
}
public void setClusterNodes(String clusterNodes) {
this.clusterNodes = clusterNodes;
}
public boolean isCheckEnabled() {
return checkEnabled;
}
public void setCheckEnabled(boolean checkEnabled) {
this.checkEnabled = checkEnabled;
}
}