java如何寻找main函数对应的类
2018-01-23 09:19
190 查看
参考springboot
Class<?> deduceMainApplicationClass() { try { StackTraceElement[] stackTrace = new RuntimeException().getStackTrace(); for (StackTraceElement stackTraceElement : stackTrace) { if ("main".equals(stackTraceElement.getMethodName())) { return Class.forName(stackTraceElement.getClassName()); } } } catch (ClassNotFoundException ex) { // Swallow and continue } return null; }
相关文章推荐
- 如何在IJ中使用Jaxb2通过xml定义生成对应的Java Entity类的文件
- 如何找到java对应的c/c++源码
- Tomcat 7 如何手工部署war包对应的Java项目
- 如何找到java对应的c/c++源码
- java的大端小端和c#如何对应
- 如何找到java对应的c/c++源码
- Tomcat 7 如何手工部署war包对应的Java项目
- Android中如何根据端口号寻找对应的进程
- 如何将一个json字符串当成一个JSON对应来使用,在java中
- (转)Map java中的map 如何修改Map中的对应元素
- Mapper.java 与 Mapper.xml 如何对应
- Java 如何在Main函数中,执行完异步任务后才退出主线程
- java 中如何遍历hashMap的key所对应的value?
- JAVA中main函数参数args,以及如何给args传参
- Retrofit2.0中如何创建JSON所对应的javaBean
- Android JNI中Java与C++对象如何建立一一对应的关系
- Tomcat 7 如何手工部署war包对应的Java项目
- 如何获取Java层的函数在Dalvik中对应的Method?
- 问题 Java中的监听器类如何自动选择对应事件的方法执行的?
- 如何封装HAL API以及对应的JAVA API