1,创建Maven 项目 html
a,新建Spring template project spring
b,选择 spring mvc apache
2,向Maven的本地仓库添加jar包 (http://maven.apache.org/plugins/maven-install-plugin/examples/specific-local-repo.html) mvc
A,在doc中 app
mvn install:install-file -Dfile=path-to-your-artifact-jar maven
-DgroupId=your.groupId this
-DartifactId=your-artifactId spa
-Dversion=version code
-Dpackaging=jar xml
-DlocalRepositoryPath=path-to-specific-local-repo
Shell中
mvn install:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DlocalRepositoryPath=path-to-specific-local-repo
B,在pom.xml中的Dependencies中配置选项并选择阶段
3,Maven项目获取resources下面的文件内容
A, 类加载
InputStream is = this.getClass().getResourceAsStream("/META-INF/app.properties");
或者
InputStream is = this.getClass().getClassLoader().getResourceAsStream("META-INF/app.properties");
B, FileInputStream
new FileInputStream(System.getProperty("user.dir")+"\\src\\main\\resources\\META-INF\\app.properties");