打包程序优化,直接打成war包,包含容器,支持脚本运行

This commit is contained in:
thinkgem
2018-02-10 22:51:29 +08:00
parent c304dd05c1
commit d6f963b3be
17 changed files with 45 additions and 26 deletions

View File

@@ -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();
}

View File

@@ -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()]));
}
}

View File

@@ -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);
}

View File

@@ -14,6 +14,6 @@
</root>
<!-- Framework level setting -->
<include resource="logger-core.xml"/>
<include resource="config/logger-core.xml"/>
</configuration>

View File

@@ -100,7 +100,9 @@
</includes> -->
<archive>
<manifest>
<!-- caution: add directory entries -->
<!-- Add directory entries -->
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addClasspath>true</addClasspath>
</manifest>
</archive>

View File

@@ -15,7 +15,7 @@
<property name="context-root" value="jeesite-web"/>
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
<property name="java-output-path" value="/src/main/webapp/WEB-INF/classes"/>
<property name="component.exclusion.patterns" value="userfiles/**,test/**"/>
<property name="component.exclusion.patterns"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>

View File

@@ -14,20 +14,12 @@ rem echo.
cd %~dp0
cd ../
title %cd%
set currPath=%cd%
title %cd%
rem set MAVEN_OPTS=%MAVEN_OPTS% -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m
set MAVEN_OPTS=%MAVEN_OPTS% -Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
if exist "../package/pom.xml" (
cd ../package
call mvn clean install -Dmaven.test.skip=true -Ppackage -U
)
cd %currPath%
call mvn clean spring-boot:run -U
pause

View File

@@ -5,7 +5,7 @@ rem *
rem * Author: ThinkGem@163.com
rem */
echo.
echo [信息] 运行Web工程。
echo [信息] 打包Web工程运行Web工程。
echo.
rem pause
rem echo.
@@ -14,12 +14,17 @@ rem echo.
cd %~dp0
cd ../
call mvn clean package spring-boot:repackage -Dmaven.test.skip=true -U
title %cd%
rem set JAVA_OPTS= -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m
set JAVA_OPTS= -Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
cd target/
java -jar jeesite-web.war
call unzip -n jeesite-web.war -d jeesite-web
cd jeesite-web
call java org.springframework.boot.loader.WarLauncher
pause

View File

@@ -9,7 +9,7 @@ jdbc:
# Mysql 数据库配置
type: mysql
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/jeesite4?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
url: jdbc:mysql://127.0.0.1:3306/jeesite4?useSSL=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
username: root
password: 123456
testSql: SELECT 1

View File

@@ -56,6 +56,6 @@
</root>
<!-- Framework level setting -->
<include resource="logger-core.xml"/>
<include resource="config/logger-core.xml"/>
</configuration>

View File

@@ -23,8 +23,8 @@ public class InitGenData extends com.jeesite.modules.gen.db.InitGenData {
@Test
public void initGenData() throws Exception{
createGenTable();
initGenTreeData();
initGenTestData();
initGenTreeData();
}
}