打包程序优化,直接打成war包,包含容器,支持脚本运行
This commit is contained in:
@@ -6,6 +6,7 @@ package com.jeesite.common.io;
|
|||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -18,9 +19,6 @@ import javax.activation.MimetypesFileTypeMap;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.Charsets;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.tools.zip.ZipEntry;
|
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.collect.ListUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
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();
|
projectPath = file.toString();
|
||||||
}
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -998,6 +1001,8 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
|||||||
}
|
}
|
||||||
webappPath = file.toString();
|
webappPath = file.toString();
|
||||||
}
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
|
import com.jeesite.common.collect.SetUtils;
|
||||||
import com.jeesite.common.lang.ObjectUtils;
|
import com.jeesite.common.lang.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,8 +31,9 @@ public class PropertiesUtils {
|
|||||||
|
|
||||||
// 默认加载的文件,可通过继承覆盖(若有相同Key,优先加载后面的)
|
// 默认加载的文件,可通过继承覆盖(若有相同Key,优先加载后面的)
|
||||||
public static final String[] DEFAULT_CONFIG_FILE = new String[]{
|
public static final String[] DEFAULT_CONFIG_FILE = new String[]{
|
||||||
"classpath:jeesite-core.yml", "classpath:jeesite.yml",
|
"classpath:config/jeesite.yml",
|
||||||
"classpath:config/application.yml", "classpath:application.yml"};
|
"classpath:config/application.yml",
|
||||||
|
"classpath:application.yml"};
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(PropertiesUtils.class);
|
private static Logger logger = LoggerFactory.getLogger(PropertiesUtils.class);
|
||||||
|
|
||||||
@@ -45,7 +48,16 @@ public class PropertiesUtils {
|
|||||||
releadInstance();
|
releadInstance();
|
||||||
}
|
}
|
||||||
public static void 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){
|
public static Resource[] getResources(String locationPattern){
|
||||||
try {
|
try {
|
||||||
return new PathMatchingResourcePatternResolver()
|
Resource[] resources = new PathMatchingResourcePatternResolver()
|
||||||
.getResources(locationPattern);
|
.getResources(locationPattern);
|
||||||
|
// System.out.println("===========\n===========");
|
||||||
|
// System.out.println(locationPattern + " : " + resources.length);
|
||||||
|
// System.out.println("===========\n===========");
|
||||||
|
return resources;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw ExceptionUtils.unchecked(e);
|
throw ExceptionUtils.unchecked(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,6 @@
|
|||||||
</root>
|
</root>
|
||||||
|
|
||||||
<!-- Framework level setting -->
|
<!-- Framework level setting -->
|
||||||
<include resource="logger-core.xml"/>
|
<include resource="config/logger-core.xml"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -100,7 +100,9 @@
|
|||||||
</includes> -->
|
</includes> -->
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<!-- caution: add directory entries -->
|
<!-- Add directory entries -->
|
||||||
|
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||||
|
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
|
||||||
<addClasspath>true</addClasspath>
|
<addClasspath>true</addClasspath>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<property name="context-root" value="jeesite-web"/>
|
<property name="context-root" value="jeesite-web"/>
|
||||||
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
|
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
|
||||||
<property name="java-output-path" value="/src/main/webapp/WEB-INF/classes"/>
|
<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/java"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
|
|||||||
@@ -14,20 +14,12 @@ rem echo.
|
|||||||
cd %~dp0
|
cd %~dp0
|
||||||
|
|
||||||
cd ../
|
cd ../
|
||||||
title %cd%
|
|
||||||
|
|
||||||
set currPath=%cd%
|
title %cd%
|
||||||
|
|
||||||
rem set MAVEN_OPTS=%MAVEN_OPTS% -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m
|
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
|
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
|
call mvn clean spring-boot:run -U
|
||||||
|
|
||||||
pause
|
pause
|
||||||
@@ -5,7 +5,7 @@ rem *
|
|||||||
rem * Author: ThinkGem@163.com
|
rem * Author: ThinkGem@163.com
|
||||||
rem */
|
rem */
|
||||||
echo.
|
echo.
|
||||||
echo [信息] 运行Web工程。
|
echo [信息] 打包Web工程,并运行Web工程。
|
||||||
echo.
|
echo.
|
||||||
rem pause
|
rem pause
|
||||||
rem echo.
|
rem echo.
|
||||||
@@ -14,12 +14,17 @@ rem echo.
|
|||||||
cd %~dp0
|
cd %~dp0
|
||||||
|
|
||||||
cd ../
|
cd ../
|
||||||
|
call mvn clean package spring-boot:repackage -Dmaven.test.skip=true -U
|
||||||
|
|
||||||
title %cd%
|
title %cd%
|
||||||
|
|
||||||
rem set JAVA_OPTS= -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m
|
rem set JAVA_OPTS= -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m
|
||||||
set JAVA_OPTS= -Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
set JAVA_OPTS= -Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||||
|
|
||||||
cd target/
|
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
|
pause
|
||||||
@@ -15,4 +15,3 @@ server:
|
|||||||
|
|
||||||
debug: true
|
debug: true
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ jdbc:
|
|||||||
# Mysql 数据库配置
|
# Mysql 数据库配置
|
||||||
type: mysql
|
type: mysql
|
||||||
driver: com.mysql.jdbc.Driver
|
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
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
testSql: SELECT 1
|
testSql: SELECT 1
|
||||||
@@ -56,6 +56,6 @@
|
|||||||
</root>
|
</root>
|
||||||
|
|
||||||
<!-- Framework level setting -->
|
<!-- Framework level setting -->
|
||||||
<include resource="logger-core.xml"/>
|
<include resource="config/logger-core.xml"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -23,8 +23,8 @@ public class InitGenData extends com.jeesite.modules.gen.db.InitGenData {
|
|||||||
@Test
|
@Test
|
||||||
public void initGenData() throws Exception{
|
public void initGenData() throws Exception{
|
||||||
createGenTable();
|
createGenTable();
|
||||||
initGenTreeData();
|
|
||||||
initGenTestData();
|
initGenTestData();
|
||||||
|
initGenTreeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user