java 无法解析项目的依赖项。找不到神器。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48450025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 10:04:13  来源:igfitidea点击:

Could not resolve dependencies for project. Could not find artifact.

javamavendependenciespom.xml

提问by tomas123

I have a problem with building a project Farma-rest which depends on my other project Farma. I put dependency in my pom.xml but it couldn't resolve dependencies for the project. It shows me this error message:

我在构建一个依赖于我的另一个项目 Farma 的项目 Farma-rest 时遇到问题。我在 pom.xml 中添加了依赖项,但它无法解析项目的依赖项。它向我显示此错误消息:

Failed to execute goal on project Farma-rest: Could not resolve dependencies for project sk.upjs.ics:Farma-rest:jar:1.0-SNAPSHOT: Could not find artifact sk.upjs.ics:Farma:jar:1.0-SNAPSHOT -> [Help 1]

无法在 Farma-rest 项目上执行目标:无法解决项目 sk.upjs.ics:Farma-rest:jar:1.0-SNAPSHOT 的依赖项:找不到工件 sk.upjs.ics:Farma:jar:1.0-SNAPSHOT - > [帮助1]

Here is the pom of the first project:

这是第一个项目的pom:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>sk.upjs.ics</groupId>
    <artifactId>Farma</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.8-dmr</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <scope>test</scope>
            <version>2.44.0</version>
        </dependency>
        <dependency>
            <groupId>com.opera</groupId>
            <artifactId>operadriver</artifactId>
            <scope>test</scope>
            <version>1.5</version>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-remote-driver</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

And here is the POM of the project which I want to build:

这是我要构建的项目的 POM:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>sk.upjs.ics</groupId>
    <artifactId>Farma-rest</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <scope>test</scope>
        </dependency> 
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.8-dmr</version>
        </dependency>

        <dependency>
            <groupId>sk.upjs.ics</groupId>
            <artifactId>Farma</artifactId>
            <version>1.0-SNAPSHOT</version>
            <!-- <scope>compile</scope>-->
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.Hymanson.datatype/Hymanson-datatype-jsr310 -->
        <dependency>
            <groupId>com.fasterxml.Hymanson.datatype</groupId>
            <artifactId>Hymanson-datatype-jsr310</artifactId>
            <version>2.9.3</version>
        </dependency>

    </dependencies>
</project>

I tried to clean and build the project but it didn't helped.

我试图清理和构建项目,但没有帮助。

采纳答案by ilooner

The jar for the Farmaproject is not available in your local maven repo.

Farma项目的 jar在您的本地 Maven 存储库中不可用。

  1. Check if the ~/.m2/repository/sk.upjs.ics/Farma/1.0-SNAPSHOTdirectory exists. It should not at this point.
  2. Run the build for the Farmaproject. Maven should create the artifact and put it in your local maven repository.
  3. Check the same directory as before. It should now exist and it should have a jar and pom in it.
  4. Now try building Farma-restagain and it should work.
  1. 检查~/.m2/repository/sk.upjs.ics/Farma/1.0-SNAPSHOT目录是否存在。此时不应该。
  2. 运行Farma项目的构建。Maven 应该创建工件并将其放入您的本地 Maven 存储库中。
  3. 检查与以前相同的目录。它现在应该存在,并且里面应该有一个 jar 和 pom。
  4. 现在尝试再次构建Farma-rest,它应该可以工作。