Classloader issues - How to determine which library versions (jar-files) are loaded

前端 未结 5 1186
予麋鹿
予麋鹿 2020-12-13 18:57

I\'ve just solved another *I-though-I-was-using-this-version-of-a-library-but-apparently-my-app-server-has-already-loaded-an-older-version-of-this-library-*issue (sigh).

5条回答
  •  猫巷女王i
    2020-12-13 19:40

    There must be a better way than the way I do it, but I tend to do this in a very manual way.

    1. Every Jar must have it's version number in the file name (if it doesn't change it's name).
    2. each application has it's own classpath.
    3. There must be a reason to start using an updated Jar (new version). Don't just change because it is available, change because it gives you functionality that you need.
    4. Each release must include all Jars that are needed.
    5. I keep a Version class that knows the list of Jars it needs (this is coded into the source file) and can be checked at runtime against the list of Jars in the classpath.

    As I said, it is manual, but it works.

提交回复
热议问题