3

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:

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]

Here is the pom of the first project:

    <?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:

    <?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.jackson.datatype/jackson-datatype-jsr310 -->
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>2.9.3</version>
        </dependency>

    </dependencies>
</project>

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

tomas123
  • 33
  • 1
  • 1
  • 3
  • Possible duplicate of [Maven Could not resolve dependencies, artifacts could not be resolved](https://stackoverflow.com/questions/4650460/maven-could-not-resolve-dependencies-artifacts-could-not-be-resolved) – clinomaniac Jan 25 '18 at 19:11
  • Excuse me, but did you verify if the Farma jar is installed in your local maven repository? – Andre Piantino Jan 25 '18 at 19:29
  • which is obviously not the case as @AndrePiantino wrote... – khmarbaise Jan 25 '18 at 21:19

1 Answers1

4

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

  1. Check if the ~/.m2/repository/sk.upjs.ics/Farma/1.0-SNAPSHOT directory exists. It should not at this point.
  2. Run the build for the Farma project. 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-rest again and it should work.
ilooner
  • 2,480
  • 15
  • 32
  • 1
    Thanks a lot. I realised, that some unit tests weren't working in project Farma so maven couldn't build jar and put it in my local maven repository. I fixed it, so now it is working. – tomas123 Jan 26 '18 at 07:32
  • @tomas123 can you elaborate on that? I'm having the same issue – ancm Jun 04 '19 at 23:24