【问题标题】:Why class loader function doesnot executed while running jar using maven为什么在使用 maven 运行 jar 时不执行类加载器函数
【发布时间】:2017-03-27 06:36:45
【问题描述】:

您好,我正在使用 maven3 构建我的项目。我可以使用 maven clean、maven build、maven package 命令生成 jar 文件。我的应用程序包含使用石英调度程序的调度程序功能。使用 java -jar jarname.jar 执行 jar,它开始运行,但在类加载器函数处停止,该函数在 eclipse 中完美运行。它没有显示任何异常。当使用导出选项创建 jar 时,它运行完美,而不是在 eclipse 中使用 maven。

这是我使用类加载器函数的代码

public void classLoadder(String comNam, JmsTemplate jtScrap, JmsTemplate jtExpiry){
    String classFullName = "org.scrappers.Scrap."+ comNam ;         

    try{
        Class<?> cl = Class.forName( classFullName );
        Class<?>[] argTypes = new Class[] { JmsTemplate.class,JmsTemplate.class };
        Object obj = cl.newInstance();
        Method method = cl.getMethod("scrapAndIndex", argTypes);
        method.invoke(obj, (Object) jtScrap, (Object) jtExpiry);
    }catch(Exception e){
        e.printStackTrace();
    }
}

【问题讨论】:

  • 如果没有错误信息,你怎么知道它停在那里?!
  • 我相信这里的 Maven 错误和/或堆栈跟踪将是有用的附录。

标签: java maven jar


【解决方案1】:

检查有关 maven 的 eclipse 配置。如果您可以在 eclipse 之外运行它,那么错误必须在您的环境中。

【讨论】:

    猜你喜欢
    • 2020-12-02
    • 1970-01-01
    • 1970-01-01
    • 2012-08-26
    • 2016-05-19
    • 1970-01-01
    • 2014-11-18
    • 2015-03-06
    • 2020-09-24
    相关资源
    最近更新 更多