开发者

Problem with Apache Commons Id UUID Version 1 generation

开发者 https://www.devze.com 2022-12-13 16:45 出处:网络
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).

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?


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

  • Java Uuid Generator (JUG)
  • UUID 3.1

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

0

精彩评论

暂无评论...
验证码 换一张
取 消