maven工程创建

1、eclipse创建maven工程

参考:https://blog.csdn.net/u014079773/article/details/50098315

2、maven创建resources目录

maven 创建新工程,有些模板(比如 maven-archetype-quickstart)默认没有resources目录,那么如何手动添加resources:
参考, maven项目添加resources目录:https://blog.csdn.net/weixin_34252090/article/details/91584347

3、maven读取resources

参考: https://bbs.huaweicloud.com/blogs/294559

package com.xx.xx.common;
public class Test{
	public static void main(String[] args) throws IOException {
		
		URL url = Test.class.getResource("/product_property_info.txt"); 
		String filename = url.getPath(); 
		System.out.println(filename); // /demo/target/classes/name.txt 
		BufferedReader reader = new BufferedReader(new FileReader(filename)); 
		String  line = null; 
		while ((line = reader.readLine())!= null){ 
			System.out.println(line); 
		} 
		reader.close(); 
	}
}
posted @ 2023-01-30 16:09  chease  阅读(28)  评论(0)    收藏  举报