简体   繁体   中英

Gradle don't import VertX library in Eclipse

I imported a java project on eclipse where there is build.gradle as follow:

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
}

repositories {
    jcenter()
}

dependencies {

    implementation 'io.vertx:vertx-core:4.2.6'    
    implementation 'io.vertx:vertx-web:4.2.6'
    implementation 'io.vertx:vertx-web-client:4.2.6'
    implementation 'io.vertx:vertx-mqtt:4.2.6'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.13.2'

    /* for logging */
    implementation 'org.slf4j:slf4j-api:1.7.25'
    implementation 'org.slf4j:slf4j-jdk14:1.7.36'
}

But eclipse show an error "The import io cannot be resolved", in the code:

import io.vertx.core.Vertx;

/*
 * Data Service as a vertx event-loop 
 */
public class RunService {


    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        DataService service = new DataService(8080);
        vertx.deployVerticle(service);
    }
}

What can i do?

You need to tell Gradle to make the dependency jar files available to your IDE, here Eclipse. Add the Eclipse plugin to your plugins:

plugins {
    id 'java-library'
    id 'eclipse'
}

Then run gradle eclipse and refresh the project in Eclipse.

JCenter was deprecated and made read-only last year. Newer versions from this year, like the ones you're trying to use, will never be on JCenter. You need to replace it with mavenCentral() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM