ClassNotFoundException IDE和command line?

新手上路,请多包涵

通过Class.forName动态加载类时,本地直接通过IDE执行程序,但是线上则是mvn打包之后,通过命令行执行程序,然后发现,当发生ClassNotFoundException时,两种执行方式的花费时间相差较大,本地执行只需要10ms左右,命令行的执行方式则要花费10倍左右,请问有人知道是因为什么原因吗?完整代码如下:
public static void main(String[] args) {

    long startTs = System.currentTimeMillis();
    for (int i = 0; i < 3000; i++) {
        try {
            Class.forName("com.baidu.galaxy.queryservice.service.filter.A");
        } catch (ClassNotFoundException e) {
        }
    }
    long endTs = System.currentTimeMillis();
    System.out.println(endTs - startTs);
}
阅读 736
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题