Easy way to get the jar package version

Source: Internet
Author: User
easy way to get the jar package version jar packages for MAVEN management

The following files are available in the MAVEN packaged project:

The version number information for the jar package is included in the pom.properties:

To this point has come out of the method, read the file version can be.

Take MyBatis as an example:

For different projects, the pom.properties path is not the same and can only be obtained for the jar package. include version number for jar package name

We can get the full path to the jar package by code and then get the version number by intercepting the string.

We need to use one of the classes contained in the JAR package.

For example, for MyBatis:

String jarpath = SqlSession.class.getProtectionDomain (). Getcodesource (). GetLocation (). GetFile ();
Get/x:/xxxx/xx/mybatis-3.2.8.jar

The string is then processed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.