`
skzr.org
  • 浏览: 355409 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

storm topology all in one spring文件合并

阅读更多

storm生成topology all in one的jar包时,如果是spring环境,就会出现问题,各种资源文件无法找到,写了个工具方法,合并并生成这些资源文件:

 

public class MergeMetaInf {

	public static void main(String[] args) throws IOException, URISyntaxException {
		File metaInfDir = new File("src/main/resources");
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
		for (String name : new String[] {"META-INF/spring.factories", "META-INF/spring.handlers", "META-INF/spring.schemas", "META-INF/spring.tooling"}) {

			File file = new File(metaInfDir, name);
			if (!file.getParentFile().exists()) file.getParentFile().mkdirs();
			try (OutputStream out = new FileOutputStream(file)) {
				
				for (Enumeration<URL> iter = classLoader.getResources(name); iter.hasMoreElements();) {
					URL url = iter.nextElement();
					if (!url.getProtocol().equals("file")) {
						UtilIO.write(url.openStream(), out);
						out.write('\n');
					}
				}
			}
		}
	}
}

 

分享到:
评论
1 楼 skzr.org 2016-05-02  
jdbc:mysql://localhost:3306/?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

相关推荐

Global site tag (gtag.js) - Google Analytics