Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Husen committed Dec 14, 2017
1 parent f4b5c14 commit 44dc16b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
6 changes: 1 addition & 5 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_121">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.5">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
Expand All @@ -16,5 +11,6 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion .settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="java-output-path" value="/web/build/classes"/>
<property name="context-root" value="web"/>
<property name="context-root" value="/"/>
</wb-module>
</project-modules>
2 changes: 1 addition & 1 deletion config/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Properties>
<!-- 云端部署 这里的logs为项目根目录下的logs文件夹 -->
<!-- web:rootDir指向web应用根目录,需使用log4j-web.jar -->
<Property name="log_path">F:\workspace\workspace pers\web/logs</Property>
<Property name="log_path">G:\workspace\workspace pers\web/logs</Property>
<!-- 本地开发使用绝对路径定义日志 -->
<!-- <Property name="log_path">${web:rootDir}\logs</Property> -->

Expand Down
27 changes: 16 additions & 11 deletions src/pers/husen/web/config/ProjectDeployConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ProjectDeployConfig {
/** 工程部署路径,如 本地为 web\WebContent\, 服务器为/web **/
public static File WEB_DEPLOY_PATH;

/** 工程根目录路径 如 /web **/
/** 工程根目录路径 ,web的同级目录 **/
public static String WEB_ROOT_PATH;

/** 日志配置文件路径 */
Expand All @@ -45,16 +45,6 @@ public class ProjectDeployConfig {
* @param deployPath
*/
public static void setGlobalVariable(String deployPath) {
WEB_DEPLOY_PATH = new File(deployPath);
WEB_ROOT_PATH = WEB_DEPLOY_PATH.getParent();

LOG4J2_CONFIG_PATH = WEB_ROOT_PATH + CommonConstants.LOG4J2_CONFIG_FILE_RELATIVE_PATH;
DB_CONNECT_INFO_FILE_PATH = WEB_ROOT_PATH + CommonConstants.DB_CONNECT_INFO_FILE_RELATIVE_PATH;

LOG4J2_OUT_PATH = WEB_ROOT_PATH + CommonConstants.LOG_OUT_FILE_RELATIVE_PATH;
DOWNLOAD_PATH = WEB_ROOT_PATH + CommonConstants.DOWNLOAD_FILE_RELATIVE_PATH;
IMAGE_PATH = WEB_ROOT_PATH + CommonConstants.IMAGE_UPLOAD_FILE_PATH;

/**
* 根据os.name判断当前是本地开发还是远程部署
* 在centos为 Linux,
Expand All @@ -71,5 +61,20 @@ public static void setGlobalVariable(String deployPath) {
Logger logger = LogManager.getLogger(WebInitConfigListener.class);
logger.fatal("识别 user.dir -> " + currOsName + " 出错,使用log4j2默认配置");
}

if(IS_REMOTE_DEPLOY) {
WEB_DEPLOY_PATH = new File(deployPath);
}else {
WEB_DEPLOY_PATH = new File("G:/workspace/workspace pers/web/WebContent/");
}

WEB_ROOT_PATH = WEB_DEPLOY_PATH.getParent();

LOG4J2_CONFIG_PATH = WEB_ROOT_PATH + CommonConstants.LOG4J2_CONFIG_FILE_RELATIVE_PATH;
DB_CONNECT_INFO_FILE_PATH = WEB_ROOT_PATH + CommonConstants.DB_CONNECT_INFO_FILE_RELATIVE_PATH;

LOG4J2_OUT_PATH = WEB_ROOT_PATH + CommonConstants.LOG_OUT_FILE_RELATIVE_PATH;
DOWNLOAD_PATH = WEB_ROOT_PATH + CommonConstants.DOWNLOAD_FILE_RELATIVE_PATH;
IMAGE_PATH = WEB_ROOT_PATH + CommonConstants.IMAGE_UPLOAD_FILE_PATH;
}
}

0 comments on commit 44dc16b

Please sign in to comment.