Apache Commons Id UUID 版本 1 生成问题

发布于 2024-08-13 15:46:14 字数 1052 浏览 2 评论 0原文

我的问题是生成版本 1 UUID。我们使用 Jetty 6.x、Maven(用于启动 Jetty 等)和 Apache Commons ID(从当前时间生成 UUID 版本 1)。

Apache Commons ID 需要一个使用参数告知 JVM 的配置文件,例如'org.apache.commons.id.uuid.config.resource.filename=commons-id-uuid.xml'。我检查了 Apache Commons ID 代码,它尝试从类路径中查找该文件。 Jetty 的 文档 指出 WEB-INF/lib 和 WEB-INF/classes 位于类路径。可以从 WEB-INF/classes 目录根部部署的 war 文件中找到“commons-id-uuid.xml”,但 Jetty 无法加载它:

Message: java.lang.RuntimeException: 
java.lang.IllegalStateException: commons-id-uuid.xml loaded as system resource is null

Jetty 是使用以下命令启动的:

mvn jetty:run -Dorg.apache.commons.id.uuid.config.resource.filename=commons-id-uuid.xml

知道出了什么问题吗?我们只需要生成 UUID 版本 1 标识符。有什么建议吗?

My problem is to generate version 1 UUIDs. We use Jetty 6.x, Maven (to start Jetty among other things) and Apache Commons ID (to generate UUID version 1 from the current time).

Apache Commons ID requires a configuration file that is told to the JVM, using a parameter, e.g. 'org.apache.commons.id.uuid.config.resource.filename=commons-id-uuid.xml'. I checked the Apache Commons ID code and it tries to find the file from the classpath. Jetty's documentation states that WEB-INF/lib and WEB-INF/classes are in the classpath. The 'commons-id-uuid.xml' can be found from the deployed war file from the root of WEB-INF/classes directory but Jetty cannot load it:

Message: java.lang.RuntimeException: 
java.lang.IllegalStateException: commons-id-uuid.xml loaded as system resource is null

Jetty was started using the following command:

mvn jetty:run -Dorg.apache.commons.id.uuid.config.resource.filename=commons-id-uuid.xml

Any idea what is going wrong? We just need to generate UUID version 1 identifiers. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So要识趣 2024-08-20 15:46:14

至少有 2 个比 apache commons 更好的 UUID 生成库:

不需要 xml 配置文件。也许可以考虑其中之一?

There are at least 2 better UUID generation libraries than apache commons one:

which do not require xml config files. Maybe consider one of them instead?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文