From d6f963b3bebc44a7d292adf0a62570704351e951 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Sat, 10 Feb 2018 22:51:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85=E7=A8=8B=E5=BA=8F=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E7=9B=B4=E6=8E=A5=E6=89=93=E6=88=90war?= =?UTF-8?q?=E5=8C=85=EF=BC=8C=E5=8C=85=E5=90=AB=E5=AE=B9=E5=99=A8=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=84=9A=E6=9C=AC=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jeesite/common/io/FileUtils.java | 11 ++++++++--- .../com/jeesite/common/io/PropertiesUtils.java | 18 +++++++++++++++--- .../com/jeesite/common/io/ResourceUtils.java | 8 ++++++-- .../{ => config}/beetl-core.properties | 0 .../resources/{ => config}/jeesite-core.yml | 0 .../resources/{ => config}/logger-core.xml | 0 .../core/src/test/resource/logback-test.xml | 2 +- parent/pom.xml | 4 +++- web/.settings/org.eclipse.wst.common.component | 2 +- web/bin/run-tomcat.bat | 10 +--------- web/bin/{startup.bat => run-war.bat} | 9 +++++++-- .../resources/{ => config}/application.yml | 1 - .../resources/{ => config}/beetl.properties | 0 .../main/resources/{ => config}/jeesite.yml | 2 +- .../main/resources/{ => config}/ueditor.json | 0 web/src/main/resources/logback.xml | 2 +- .../java/com/jeesite/test/InitGenData.java | 2 +- 17 files changed, 45 insertions(+), 26 deletions(-) rename modules/core/src/main/resources/{ => config}/beetl-core.properties (100%) rename modules/core/src/main/resources/{ => config}/jeesite-core.yml (100%) rename modules/core/src/main/resources/{ => config}/logger-core.xml (100%) rename web/bin/{startup.bat => run-war.bat} (59%) rename web/src/main/resources/{ => config}/application.yml (89%) rename web/src/main/resources/{ => config}/beetl.properties (100%) rename web/src/main/resources/{ => config}/jeesite.yml (83%) rename web/src/main/resources/{ => config}/ueditor.json (100%) diff --git a/common/src/main/java/com/jeesite/common/io/FileUtils.java b/common/src/main/java/com/jeesite/common/io/FileUtils.java index 174c794d..a476533c 100644 --- a/common/src/main/java/com/jeesite/common/io/FileUtils.java +++ b/common/src/main/java/com/jeesite/common/io/FileUtils.java @@ -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(); } diff --git a/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java b/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java index a3fd4b61..fa460594 100644 --- a/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java +++ b/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java @@ -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 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()])); } } diff --git a/common/src/main/java/com/jeesite/common/io/ResourceUtils.java b/common/src/main/java/com/jeesite/common/io/ResourceUtils.java index 0abc0b12..21041db2 100644 --- a/common/src/main/java/com/jeesite/common/io/ResourceUtils.java +++ b/common/src/main/java/com/jeesite/common/io/ResourceUtils.java @@ -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); } diff --git a/modules/core/src/main/resources/beetl-core.properties b/modules/core/src/main/resources/config/beetl-core.properties similarity index 100% rename from modules/core/src/main/resources/beetl-core.properties rename to modules/core/src/main/resources/config/beetl-core.properties diff --git a/modules/core/src/main/resources/jeesite-core.yml b/modules/core/src/main/resources/config/jeesite-core.yml similarity index 100% rename from modules/core/src/main/resources/jeesite-core.yml rename to modules/core/src/main/resources/config/jeesite-core.yml diff --git a/modules/core/src/main/resources/logger-core.xml b/modules/core/src/main/resources/config/logger-core.xml similarity index 100% rename from modules/core/src/main/resources/logger-core.xml rename to modules/core/src/main/resources/config/logger-core.xml diff --git a/modules/core/src/test/resource/logback-test.xml b/modules/core/src/test/resource/logback-test.xml index a5bc790a..5355eba7 100644 --- a/modules/core/src/test/resource/logback-test.xml +++ b/modules/core/src/test/resource/logback-test.xml @@ -14,6 +14,6 @@ - + \ No newline at end of file diff --git a/parent/pom.xml b/parent/pom.xml index 0116a40e..590666aa 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -100,7 +100,9 @@ --> - + + true + true true diff --git a/web/.settings/org.eclipse.wst.common.component b/web/.settings/org.eclipse.wst.common.component index 1e044cdf..b6879580 100644 --- a/web/.settings/org.eclipse.wst.common.component +++ b/web/.settings/org.eclipse.wst.common.component @@ -15,7 +15,7 @@ - + diff --git a/web/bin/run-tomcat.bat b/web/bin/run-tomcat.bat index 4f9608c4..24a3eb39 100644 --- a/web/bin/run-tomcat.bat +++ b/web/bin/run-tomcat.bat @@ -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 \ No newline at end of file diff --git a/web/bin/startup.bat b/web/bin/run-war.bat similarity index 59% rename from web/bin/startup.bat rename to web/bin/run-war.bat index 7ec1d3eb..f5097f60 100644 --- a/web/bin/startup.bat +++ b/web/bin/run-war.bat @@ -5,7 +5,7 @@ rem * rem * Author: ThinkGem@163.com rem */ echo. -echo [信息] 运行Web工程。 +echo [Ϣ] Weḅ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 \ No newline at end of file diff --git a/web/src/main/resources/application.yml b/web/src/main/resources/config/application.yml similarity index 89% rename from web/src/main/resources/application.yml rename to web/src/main/resources/config/application.yml index 7007eeba..429c9a5a 100644 --- a/web/src/main/resources/application.yml +++ b/web/src/main/resources/config/application.yml @@ -15,4 +15,3 @@ server: debug: true - diff --git a/web/src/main/resources/beetl.properties b/web/src/main/resources/config/beetl.properties similarity index 100% rename from web/src/main/resources/beetl.properties rename to web/src/main/resources/config/beetl.properties diff --git a/web/src/main/resources/jeesite.yml b/web/src/main/resources/config/jeesite.yml similarity index 83% rename from web/src/main/resources/jeesite.yml rename to web/src/main/resources/config/jeesite.yml index 9a648623..ac8a88c1 100644 --- a/web/src/main/resources/jeesite.yml +++ b/web/src/main/resources/config/jeesite.yml @@ -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 diff --git a/web/src/main/resources/ueditor.json b/web/src/main/resources/config/ueditor.json similarity index 100% rename from web/src/main/resources/ueditor.json rename to web/src/main/resources/config/ueditor.json diff --git a/web/src/main/resources/logback.xml b/web/src/main/resources/logback.xml index 4bcf3bee..0d80eece 100644 --- a/web/src/main/resources/logback.xml +++ b/web/src/main/resources/logback.xml @@ -56,6 +56,6 @@ - + \ No newline at end of file diff --git a/web/src/test/java/com/jeesite/test/InitGenData.java b/web/src/test/java/com/jeesite/test/InitGenData.java index 74bafb40..42597035 100644 --- a/web/src/test/java/com/jeesite/test/InitGenData.java +++ b/web/src/test/java/com/jeesite/test/InitGenData.java @@ -23,8 +23,8 @@ public class InitGenData extends com.jeesite.modules.gen.db.InitGenData { @Test public void initGenData() throws Exception{ createGenTable(); - initGenTreeData(); initGenTestData(); + initGenTreeData(); } }