public class Application {
public static void main(String[] args) {
// 处理未捕获的异常
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
logger.error("未处理异常:" + t.toString(), e);
}
});
// 加载Spring容器
ApplicationContext ctx = new CircularReferenceDisableApplicationContext("classpath:spring/*.xml");
synchronized (Main.class) {
while (true) {
try {
Main.class.wait();
} catch (Throwable e) {
}
}
}
}
public static void main(String[] args) {
// 处理未捕获的异常
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
logger.error("未处理异常:" + t.toString(), e);
}
});
// 加载Spring容器
ApplicationContext ctx = new CircularReferenceDisableApplicationContext("classpath:spring/*.xml");
synchronized (Main.class) {
while (true) {
try {
Main.class.wait();
} catch (Throwable e) {
}
}
}
}
}
详解:
http://blog.youkuaiyun.com/u013256816/article/details/50417822