是否有获取jSoup jar版本的方法? [英] Is there a method to get the jSoup jar version?

查看:88
本文介绍了是否有获取jSoup jar版本的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是Java程序员,而是在ColdFusion应用程序中使用jSoup,而且我的Java知识是有限的.

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

我查看了文档,但是找不到一种方法来告诉我加载了哪个版本的jSoup.也许有一个标准的Java方法吗?

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.

谢谢, 默里

推荐答案

通常,您可以向Java运行时环境提供要在类路径中某处使用的库版本,或者使用构建工具来管理以下项的依赖关系:你.

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.

例如我几乎对每个项目都使用gradle.要将gradle添加到您的项目中,请下载/安装gradle,打开一个终端,使用cd进入该项目的根目录,执行gradle init,然后在项目中最终得到一些其他文件.

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.

项目根目录中的文件之一是build.gradle,其中包含许多内容-一个是项目dependencies.这是我用于JSoup项目的一个示例:

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'
}

在这里您可以看到库依赖项的确切版本,如果要检查由于另一个库导入了您期望的其他/较新版本而导致的版本冲突,则可以使用gradle dependencies进行检查.

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.

这篇关于是否有获取jSoup jar版本的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆