【问题标题】:How to get information about maven dependency from source code?如何从源代码中获取有关 maven 依赖的信息?
【发布时间】:2020-08-02 16:36:17
【问题描述】:

我是 Java 和 Maven 的新手。

我正在关注这个关于 Cucumber in Java 的教程,但它没有提到 Maven 依赖项,例如与 Cucumber 相关的模块的 groupId 或 artifactId。

https://cucumber.netlify.app/docs/guides/browser-automation/

我的问题是,从代码库的信息中,我怎样才能获得要插入 pom.xm 的信息?

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

【问题讨论】:

标签: java maven


【解决方案1】:

任何稳定的发布版本都应该很好用。例如,我看到你可以使用 3.141.59 喜欢:

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-api -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-api</artifactId>
    <version>3.141.59</version>
</dependency>

【讨论】:

    【解决方案2】:

    至于上面的类,下面是我使用的依赖,但是你的需求和版本可能存在兼容性问题。试试下面的,看看是否有效,否则你将不得不从 maven 存储库中找到它

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-api</artifactId>
            <version>3.141.59</version> <!--Not sure the version-->
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>3.141.59</version> <!--Not sure the version-->
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-support</artifactId>
            <version>3.141.59</version> <!--Not sure the version-->
        </dependency>
    

    【讨论】:

      【解决方案3】:

      我认为您的具体问题将通过查看黄瓜安装指南得到解答。

      您的一般问题(“如何找到给定导入的 Maven 依赖项?”)并不是真正可以解决的。当然,您可以获取合格的类名并在 https://search.maven.org/ 中查找它们,但这最多只能缩小搜索范围,并且可能不会告诉您应该使用哪些工件的确切版本。

      【讨论】:

        猜你喜欢
        • 2011-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-14
        • 1970-01-01
        • 2017-01-21
        • 1970-01-01
        相关资源
        最近更新 更多