2

我的项目有很多依赖项,我告诉 winrun4j 通过设置来包含所有依赖项

classpath.1=D:\lib\*.jar

在ini文件中。

服务日志告诉我 winrun4j 正在扩展类路径并生成类路径:

[info] Expanding Classpath: D:\lib\*.jar
[info] Expanding Classpath: D:\lib\activation-1.1.1.jar
[info] Expanding Classpath: D:\lib\activemq-client-5.10.2.jar
[...]
[...]many, many other libs here
[...]
[warn] Exceeded maximum classpath size
[info] Generated Classpath: D:\lib\activation-.1.1.jar;D:\lib\activemq-client-5.10.2.jar;[...]

为什么 winrun4j 会生成这样的类路径?难道不应该只是采取

D:\lib\*.jar

?

有什么想法可以让服务在这么多依赖项下运行吗?

4

3 回答 3

3

这是众所周知的winrun4j问题,在这里没有解决和讨论:

超过最大类路径长度 #59

https://github.com/poidasmith/winrun4j/issues/59

和这里 :

添加一个 INI 选项以禁用类路径全局扩展 #67

https://github.com/poidasmith/winrun4j/issues/67

不幸的是,你没有太多的可能性。正如问题 59 所建议的,您可以将工作目录设置为模块目录。你可以留出一些字符。

D:\lib\activation-.1.1.jar;会变成lib\activation-.1.1.jar;. 您还可以检查是否需要所有依赖项。

如果还不够,您应该认真寻找替代方案,例如 JSmooth 或 Launch4J。

于 2017-01-03T09:21:05.383 回答
1

您可以构建一个 fat-JAR,在单个 JAR 文件中包含所有依赖库,而不是将所有依赖项放入 libs 文件夹并将它们添加到类路径中。

如何实现这一点很大程度上取决于您使用的构建系统(例如 gradle 或 maven)。或者您可以查看默认情况下与 fat-JAR 一起使用的 spring-boot。

于 2017-01-03T09:52:03.180 回答
1

这是 winrun4j 特定问题,您可以在 winrun4j 代码中看到这条消息是硬编码的,Classpath.cpp Github

// Check for too many results
    if(*current >= max) {
        if(!g_classpathMaxWarned) {
            Log::Warning("Exceeded maximum classpath size");
            g_classpathMaxWarned = true;
        }
        return;
}

从代码中,我无法找出确切的值,max但代码库中有单元测试将其设置为 260。

我认为,这是从哪里出现的相关问题MAX_PATH

正如另一个答案中所指出的,由于限制是硬编码的,因此问题没有得到解决。

于 2017-01-03T09:40:05.840 回答