Skip to content

Commit d02c1b0

Browse files
author
monsoon
committed
framework structure build(parse properties file)
0 parents  commit d02c1b0

File tree

7 files changed

+200
-0
lines changed

7 files changed

+200
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#Maven#
2+
target
3+
# IDEA #
4+
.idea/
5+
*.iml
6+
7+
#Eclipse#
8+
.settings
9+
.metadata/
10+
.classpath
11+
.project
12+
Servers/

frameworktest/pom.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>simple-framework</artifactId>
7+
<groupId>com.xfj</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<packaging>war</packaging>
12+
13+
<artifactId>framework-test</artifactId>
14+
15+
<dependencies>
16+
<dependency>
17+
<artifactId>simple-framework</artifactId>
18+
<groupId>com.xfj</groupId>
19+
<version>1.0-SNAPSHOT</version>
20+
</dependency>
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<version>4.12</version>
25+
</dependency>
26+
</dependencies>
27+
28+
<build>
29+
<plugins>
30+
<plugin>
31+
<groupId>org.apache.tomcat.maven</groupId>
32+
<artifactId>tomcat7-maven-plugin</artifactId>
33+
<version>2.2</version>
34+
<configuration>
35+
<path>/${project.artifactId}</path>
36+
</configuration>
37+
</plugin>
38+
</plugins>
39+
</build>
40+
41+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
simple.framework.jdbc.driver=com.mysql.jdbc.Driver111
2+
simple.framework.jdbc.url=jdbc:mysql://localhost:3306/simple
3+
simple.framework.jdbc.username=root
4+
simple.framework.jdbc.password=root
5+
6+
simple.framework.app.base_package=com.xfj.frameworktest
7+
simple.framework.app.jsp_path=/WEB-INF/view/
8+
simple.framework.jdbc.asset_path=/asset/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import org.junit.Test;
2+
import simple.xfj.framework.constant.ConfigConstant;
3+
import simple.xfj.framework.util.PropsUtil;
4+
5+
import java.util.Properties;
6+
7+
/**
8+
* Created by asus on 2017/4/17.
9+
*/
10+
public class PropertiesLoadTest {
11+
12+
@Test
13+
public void testConfig() throws Exception{
14+
Properties properties = PropsUtil.loadProperties(ConfigConstant.CONFIG_FILENAME);
15+
System.out.println(properties.getProperty(ConfigConstant.JDBC_DRIVER));
16+
17+
}
18+
19+
}

pom.xml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.xfj</groupId>
8+
<artifactId>simple-framework</artifactId>
9+
<packaging>pom</packaging>
10+
<version>1.0-SNAPSHOT</version>
11+
<modules>
12+
<module>frameworktest</module>
13+
</modules>
14+
15+
<dependencies>
16+
<!-- servlet-->
17+
<dependency>
18+
<groupId>javax.servlet</groupId>
19+
<artifactId>javax.servlet-api</artifactId>
20+
<version>3.1.0</version>
21+
<scope>provided</scope>
22+
</dependency>
23+
24+
<!-- jsp -->
25+
<dependency>
26+
<groupId>javax.servlet.jsp</groupId>
27+
<artifactId>jsp-api</artifactId>
28+
<version>2.2</version>
29+
<scope>provided</scope>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>javax.servlet</groupId>
34+
<artifactId>jstl</artifactId>
35+
<version>1.2</version>
36+
<scope>runtime</scope>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.slf4j</groupId>
41+
<artifactId>slf4j-log4j12</artifactId>
42+
<version>1.7.18</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>mysql</groupId>
46+
<artifactId>mysql-connector-java</artifactId>
47+
<version>5.1.33</version>
48+
<scope>runtime</scope>
49+
</dependency>
50+
<!-- Jackson-->
51+
<dependency>
52+
<groupId>com.fasterxml.jackson.core</groupId>
53+
<artifactId>jackson-databind</artifactId>
54+
<version>2.8.5</version>
55+
</dependency>
56+
<!-- Apache Common Lang-->
57+
<dependency>
58+
<groupId>org.apache.commons</groupId>
59+
<artifactId>commons-lang3</artifactId>
60+
<version>3.3.2</version>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>org.apache.commons</groupId>
65+
<artifactId>commons-collections4</artifactId>
66+
<version>4.0</version>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>commons-dbutils</groupId>
71+
<artifactId>commons-dbutils</artifactId>
72+
<version>1.6</version>
73+
</dependency>
74+
<!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
75+
<dependency>
76+
<groupId>commons-dbcp</groupId>
77+
<artifactId>commons-dbcp</artifactId>
78+
<version>1.4</version>
79+
</dependency>
80+
81+
82+
83+
</dependencies>
84+
85+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package simple.xfj.framework.constant;
2+
3+
/**
4+
* Created by asus on 2017/4/17.
5+
*/
6+
public class ConfigConstant {
7+
public static final String CONFIG_FILENAME = "smart.properties";
8+
public static final String JDBC_DRIVER = "simple.framework.jdbc.driver";
9+
public static final String JDBC_URL = "simple.framework.jdbc.url";
10+
public static final String JDBC_USERNAME = "simple.framework.jdbc.username";
11+
public static final String JDBC_PASSWORD = "simple.framework.jdbc.password";
12+
13+
public static final String APP_BASE_PACKAGE = "simple.framework.app.base_package";
14+
public static final String APP_JSP_PATH = "simple.framework.app.jsp_path";
15+
public static final String APP_ASSET_PATH = "simple.framework.jdbc.asset_path";
16+
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package simple.xfj.framework.util;
2+
3+
import java.io.IOException;
4+
import java.util.Properties;
5+
6+
/**
7+
* Created by asus on 2017/4/17.
8+
*/
9+
public class PropsUtil {
10+
11+
public static Properties loadProperties(String propertiesFileName) throws IOException {
12+
Properties prop = new Properties();
13+
prop.load(PropsUtil.class.getClassLoader().getResourceAsStream(propertiesFileName));
14+
return prop;
15+
}
16+
17+
18+
}

0 commit comments

Comments
 (0)