0

This is the POM file:

<?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>com.mycompany</groupId>
    <artifactId>MavenBackEndStructure</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>
    
    <dependencies>
        <dependency>
            <groupId>org.web3j</groupId>
            <artifactId>core</artifactId>
            <version>4.8.4</version>
        </dependency>
    </dependencies>

</project>

And this is my main class:

package com.mycompany.mavenbackendstructure;

import org.web3j.protocol.Web3j; //The Error is here
import org.web3j.protocol.http.HttpService; //And Here

public class Main {
    
    public static void main(String[] args){
        
        final Web3j client = new Web3j.build(
            new HttpService(
            url: "https://mainnet.infura.io/v3/435e21e85fd0498ea8fee6c77e0cc48f"
            )
        );
    }
}

I tried to search the dependency at the Maven repository but still couldn't find it, So I don't know what's the problem that making the main can't see these libraries if someone could help me.

Thanks in advance.

  • 1
    Sometimes the IDE doesn't automatically download the dependencies in the local repository so it shows it red. Try to compile on command line (mvn install...) and check if that solves the issue. If even command line compilation fails, try to check in your maven configuration whether you're pointing to the maven central repo. – Matteo NNZ May 11 '21 at 21:14
  • Matteo's comment is exactly the right idea. That's bound to get to the root of the problem fast.. If (once) mvn installs clean and your IDE *still* complains, then do a clean project maven install from your IDE, too, so it updates. – Atmas May 12 '21 at 01:59
  • First check that `ls -l ~/.m2/repository/org/web3j/` should exists. – daparic Sep 16 '22 at 14:48

0 Answers0