Skip to content

Instantly share code, notes, and snippets.

View adamish's full-sized avatar

Adam Granger adamish

View GitHub Profile
@adamish
adamish / UnusedBeans.java
Created December 8, 2016 15:26
Unreferenced spring beans across multiple files
public class UnusedBeans {
private Map<String, Node> defs = new HashMap<String, Node>();
private Set<String> refs = new HashSet<String>();
public void read() throws Exception {
String content = new String(Files.readAllBytes(Paths.get("xml.txt")));
for (String line : content.split("\n")) {
parse("../" + line.trim());
}
@adamish
adamish / XmlMerge.java
Created July 6, 2016 13:57
Merge 2 or more spring contexts to find common beans, output them to a common file, then remove them from original files. Take into account formatting differences
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;