---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.oConvertUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@ -22,6 +23,7 @@ import java.util.*;
*/
@Slf4j
@Component
@ConditionalOnProperty(prefix = "jeecg.elasticsearch", name = "cluster-nodes")
public class JeecgElasticsearchTemplate {
/** es服务地址 */
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.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.JeecgBaseConfig;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
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.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -40,9 +42,9 @@ public class JeecgController<T, S extends IService<T>> {
/**issues/2933 JeecgController注入service时改用protected修饰能避免重复引用service*/
@Autowired
protected S service;
@Value("${jeecg.path.upload}")
private String upLoadPath;
@Resource
private JeecgBaseConfig jeecgBaseConfig;
/**
* excel
*
@ -69,7 +71,7 @@ public class JeecgController<T, S extends IService<T>> {
mv.addObject(NormalExcelConstants.CLASS, clazz);
//update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
exportParams.setImageBasePath(upLoadPath);
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
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);
List<T> exportList = pageList.getRecords();
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);
//map.put("title",exportParams);
//表格Title

View File

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

View File

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

View File

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

View File

@ -12,13 +12,13 @@ import org.springframework.stereotype.Component;
@Data
public class StaticConfig {
@Value("${jeecg.oss.accessKey}")
@Value("${jeecg.oss.accessKey:}")
private String accessKeyId;
@Value("${jeecg.oss.secretKey}")
@Value("${jeecg.oss.secretKey:}")
private String accessKeySecret;
@Value(value = "${spring.mail.username}")
@Value(value = "${spring.mail.username:}")
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.UrlBasedCorsConfigurationSource;
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.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -59,12 +60,13 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
//update-begin-author:taoyan date:20211116 for: jeecg.path.webapp配置无效 #3126
.addResourceLocations("file:" + jeecgBaseConfig.getPath().getUpload() + "//")
.addResourceLocations("file:" + jeecgBaseConfig.getPath().getWebapp() + "//")
//update-end-author:taoyan date:20211116 for: jeecg.path.webapp配置无效 #3126
.addResourceLocations(staticLocations.split(","));
ResourceHandlerRegistration resourceHandlerRegistration = registry.addResourceHandler("/**");
if (jeecgBaseConfig.getPath() != null && jeecgBaseConfig.getPath().getUpload() != null) {
resourceHandlerRegistration
.addResourceLocations("file:" + jeecgBaseConfig.getPath().getUpload() + "//")
.addResourceLocations("file:" + jeecgBaseConfig.getPath().getWebapp() + "//");
}
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.util.MinioUtil;
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.Configuration;
@ -14,6 +15,7 @@ import org.springframework.context.annotation.Configuration;
*/
@Slf4j
@Configuration
@ConditionalOnProperty(prefix = "jeecg.minio.minio", name = "minio_url")
public class MinioConfig {
@Value(value = "${jeecg.minio.minio_url}")
private String minioUrl;

View File

@ -2,6 +2,7 @@ package org.jeecg.config.oss;
import org.jeecg.common.util.oss.OssBootUtil;
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.Configuration;
@ -10,6 +11,7 @@ import org.springframework.context.annotation.Configuration;
* @author: jeecg-boot
*/
@Configuration
@ConditionalOnProperty(prefix = "jeecg.oss", name = "endpoint")
public class OssConfiguration {
@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;
}
}