打包程序优化,直接打成war包,包含容器,支持脚本运行
This commit is contained in:
@@ -6,6 +6,7 @@ package com.jeesite.common.io;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -18,9 +19,6 @@ import javax.activation.MimetypesFileTypeMap;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.jmimemagic.Magic;
|
||||
import net.sf.jmimemagic.MagicMatch;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
@@ -34,6 +32,9 @@ import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
|
||||
import net.sf.jmimemagic.Magic;
|
||||
import net.sf.jmimemagic.MagicMatch;
|
||||
|
||||
/**
|
||||
* 文件操作工具类
|
||||
* 实现文件的创建、删除、复制、压缩、解压以及目录的创建、删除、复制、压缩解压等功能
|
||||
@@ -966,6 +967,8 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
}
|
||||
projectPath = file.toString();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -998,6 +1001,8 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
}
|
||||
webappPath = file.toString();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -16,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import com.jeesite.common.collect.SetUtils;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -29,8 +31,9 @@ public class PropertiesUtils {
|
||||
|
||||
// 默认加载的文件,可通过继承覆盖(若有相同Key,优先加载后面的)
|
||||
public static final String[] DEFAULT_CONFIG_FILE = new String[]{
|
||||
"classpath:jeesite-core.yml", "classpath:jeesite.yml",
|
||||
"classpath:config/application.yml", "classpath:application.yml"};
|
||||
"classpath:config/jeesite.yml",
|
||||
"classpath:config/application.yml",
|
||||
"classpath:application.yml"};
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(PropertiesUtils.class);
|
||||
|
||||
@@ -45,7 +48,16 @@ public class PropertiesUtils {
|
||||
releadInstance();
|
||||
}
|
||||
public static void releadInstance(){
|
||||
INSTANCE = new PropertiesUtils(DEFAULT_CONFIG_FILE);
|
||||
Set<String> configFiles = SetUtils.newLinkedHashSet();
|
||||
Resource[] resources = ResourceUtils.getResources("classpath*:/config/jeesite-*.*");
|
||||
for(Resource resource : resources){
|
||||
configFiles.add("classpath:/config/"+resource.getFilename());
|
||||
}
|
||||
for (String configFile : DEFAULT_CONFIG_FILE){
|
||||
configFiles.add(configFile);
|
||||
}
|
||||
logger.debug("Loading jeesite config: {}", configFiles);
|
||||
INSTANCE = new PropertiesUtils(configFiles.toArray(new String[configFiles.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,12 @@ public class ResourceUtils extends org.springframework.util.ResourceUtils {
|
||||
*/
|
||||
public static Resource[] getResources(String locationPattern){
|
||||
try {
|
||||
return new PathMatchingResourcePatternResolver()
|
||||
.getResources(locationPattern);
|
||||
Resource[] resources = new PathMatchingResourcePatternResolver()
|
||||
.getResources(locationPattern);
|
||||
// System.out.println("===========\n===========");
|
||||
// System.out.println(locationPattern + " : " + resources.length);
|
||||
// System.out.println("===========\n===========");
|
||||
return resources;
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.unchecked(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user