-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
刘义
committed
Oct 14, 2018
0 parents
commit 9f3535c
Showing
11 changed files
with
358 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5"> | ||
<output url="file:https://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file:https://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file:https://$MODULE_DIR$"> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file:https://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file:https://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file:https://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file:https://$MODULE_DIR$"> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file:https://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet.jsp:jsp-api:2.2" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" /> | ||
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:5.1.33" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.4.4" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.4.0" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.4.4" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.0" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-dbutils:commons-dbutils:1.6" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.0.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.2" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http:https://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>custom-framework</artifactId> | ||
<groupId>com.custom.framework</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>framework</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet.jsp</groupId> | ||
<artifactId>jsp-api</artifactId> | ||
<version>2.2</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>1.7.25</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.33</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.4.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-collections4</artifactId> | ||
<version>4.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-dbutils</groupId> | ||
<artifactId>commons-dbutils</artifactId> | ||
<version>1.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-dbcp2</artifactId> | ||
<version>2.0.1</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
19 changes: 19 additions & 0 deletions
19
framework/src/main/java/com/custom/framework/constants/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.custom.framework.constants; | ||
|
||
/** | ||
* @author liuyi | ||
* @date 2018/10/14 | ||
*/ | ||
public class Constants { | ||
|
||
public static final String CONFIG_FILE = "framework"; | ||
public static final String JDBC_DRIVER ="framework.jdbc.driver"; | ||
public static final String JDBC_URL = "jdbc:mysql:https://localhost:2206/demo"; | ||
public static final String JDBC_USERNAME = "framework.jdbc.username"; | ||
public static final String JDBC_PASSWORD = "framework.jdbc.password"; | ||
public static final String FRAMEWORK_JDBC_APP_BASE_PACKAGE = "framework.jdbc.app.base_package"; | ||
public static final String FRAMEWORK_JDBC_JSP_PATH = "framework.jdbc.jsp_path"; | ||
public static final String FRAMEWORK_JDBC_ASSET_PATH= "framework.jdbc.asset_path"; | ||
|
||
|
||
} |
72 changes: 72 additions & 0 deletions
72
framework/src/main/java/com/custom/framework/helper/ConfigHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.custom.framework.helper; | ||
|
||
import com.custom.framework.constants.Constants; | ||
import com.custom.framework.util.PropsUtil; | ||
|
||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* @author liuyi | ||
* @date 2018/10/14 | ||
*/ | ||
public class ConfigHelper { | ||
|
||
private static final ResourceBundle resource = PropsUtil.getResource(Constants.CONFIG_FILE); | ||
|
||
/** | ||
* 获取JDBC驱动 | ||
* @return | ||
*/ | ||
public static String getJdbcDriver() { | ||
return PropsUtil.getString(resource, Constants.JDBC_DRIVER); | ||
} | ||
|
||
/** | ||
* 获取JDBC URL | ||
* @return | ||
*/ | ||
public static String getJdbcUrl() { | ||
return PropsUtil.getString(resource, Constants.JDBC_URL); | ||
} | ||
|
||
/** | ||
* 获取JDBC 用户名 | ||
* @return | ||
*/ | ||
public static String getJdbcUsername() { | ||
return PropsUtil.getString(resource, Constants.JDBC_USERNAME); | ||
} | ||
|
||
/** | ||
* 获取JDBC 密码 | ||
* @return | ||
*/ | ||
public static String getJdbcPassword() { | ||
return PropsUtil.getString(resource, Constants.JDBC_PASSWORD); | ||
} | ||
|
||
/** | ||
* 获取应用基础包名 | ||
* @return | ||
*/ | ||
public static String getAppBasePackage() { | ||
return PropsUtil.getString(resource, Constants.FRAMEWORK_JDBC_APP_BASE_PACKAGE); | ||
} | ||
|
||
/** | ||
* 获取应用JSP路径 | ||
* @return | ||
*/ | ||
public static String getAppJspPath() { | ||
return PropsUtil.getString(resource, Constants.FRAMEWORK_JDBC_JSP_PATH); | ||
} | ||
|
||
/** | ||
* 获取应用静态资源文件路径 | ||
* @return | ||
*/ | ||
public static String getAppAssetPath() { | ||
return PropsUtil.getString(resource, Constants.FRAMEWORK_JDBC_ASSET_PATH); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
framework/src/main/java/com/custom/framework/util/PropsUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.custom.framework.util; | ||
|
||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* @author liuyi | ||
* @date 2018/10/14 | ||
*/ | ||
public class PropsUtil { | ||
|
||
/** | ||
* 根据属性文件获取资源 | ||
* @param name | ||
* @return | ||
*/ | ||
public static ResourceBundle getResource(String name) { | ||
ResourceBundle resource = ResourceBundle.getBundle(name); | ||
return resource; | ||
} | ||
|
||
/** | ||
* 根据key获取value | ||
* @param resourceBundle | ||
* @param key | ||
* @return | ||
*/ | ||
public static String getString(ResourceBundle resourceBundle, String key) { | ||
return resourceBundle.getString(key); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http:https://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.custom.framework</groupId> | ||
<artifactId>custom-framework</artifactId> | ||
<packaging>pom</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<modules> | ||
<module>framework</module> | ||
<module>test</module> | ||
</modules> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http:https://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>custom-framework</artifactId> | ||
<groupId>com.custom.framework</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>test</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.custom.framework</groupId> | ||
<artifactId>framework</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.tomcat.maven</groupId> | ||
<artifactId>tomcat7-maven-plugin</artifactId> | ||
<version>2.2</version> | ||
<configuration> | ||
<path>${project.artifactId}</path> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.custom.test; | ||
|
||
|
||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* @author liuyi | ||
* @date 2018/10/14 | ||
*/ | ||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
System.out.println(getString("framework", "framework.jdbc.asset_path")); | ||
} | ||
public static ResourceBundle getResource(String name) { | ||
ResourceBundle resource = ResourceBundle.getBundle(name); | ||
return resource; | ||
} | ||
public static String getString(String name, String key) { | ||
return getResource(name).getString(key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
framework.jdbc.driver=com.mysql.jdbc.Driver | ||
framework.jdbc.url=jdbc:mysql:https://localhost:2206/demo | ||
framework.jdbc.username=root | ||
framework.jdbc.password=root | ||
#\u9879\u76EE\u5305\u540D | ||
framework.jdbc.app.base_package=com.custom.framework.test | ||
#jsp\u7684\u57FA\u7840\u8DEF\u5F84 | ||
framework.jdbc.jsp_path=/WEB-INF/view/ | ||
#\u9759\u6001\u8D44\u6E90\u6587\u4EF6\u7684\u57FA\u7840\u8DEF\u5F84 | ||
framework.jdbc.asset_path=/asset/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5"> | ||
<output url="file:https://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file:https://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file:https://$MODULE_DIR$"> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file:https://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file:https://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="module" module-name="framework" /> | ||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" /> | ||
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:5.1.33" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.4.4" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.4.0" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.4.4" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.0" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-dbutils:commons-dbutils:1.6" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.0.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.2" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" /> | ||
</component> | ||
</module> |