Is there a method to get the jSoup jar version?

醉酒当歌 提交于 2021-02-08 11:21:40

问题


I am not a java programmer and I am using jSoup in a ColdFusion application, and my java knowledge is limited.

I looked in the docs but could not find a method to tell me which version of jSoup is loaded. Maybe there is a standard java method for that?

It is necessary because I am using it on a shared hosting and I want to ensure I have the correct compatible version loaded.

Thanks, Murray


回答1:


Usually you either supply the java runtime environment with a version of the library you want to use somewhere on the classpath, or you use a build tool to manage dependencies for you.

Typically the latter is preferred.

e.g. I use gradle for just about every project. To add gradle to your project, download/install gradle, open a terminal, cd to the project's root dir, execute gradle init and then you end up with a few additional files in your project.

One of the files in the project's root dir is build.gradle this contains many things - one is the project dependencies. Here's an example of one I use for JSoup projects:

plugins {
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

test { useJUnitPlatform() }

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.jsoup:jsoup:1.10.2'
    implementation 'com.jayway.jsonpath:json-path:2.4.0'

    testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
}

Here you can see the exact version of the library dependency and you can check it with gradle dependencies if you wanted to check for a version clash due to another library importing a different/newer version you weren't expecting.

Another method is simply to download the library and place is somewhere on the classpath so your application can access it.



来源:https://stackoverflow.com/questions/64851787/is-there-a-method-to-get-the-jsoup-jar-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!