You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询Java中第三方工具接入方法——concurrent-unique-queue仓库导入问题

Hey Leo, I’ve dealt with a few GitHub-hosted Java libraries that aren’t on Maven Central before, so let me break down exactly how to get this concurrent-unique-queue up and running in your IntelliJ project.

Option 1: Build Locally & Install to Your Local Maven Repository

Since this library isn’t published to Maven Central, the most reliable way is to build it yourself and add it to your local repo:

  • First, clone the repository to your machine using Git:
    git clone https://github.com/bvanalderweireldt/concurrent-unique-queue.git
    
  • Navigate into the cloned project directory, then run the Maven install command. This will compile the code, package it into a JAR, and add it to your local Maven repository (usually located at ~/.m2/repository):
    mvn clean install
    
    If you run into test failures during build, you can skip tests with mvn clean install -DskipTests
  • Open your IntelliJ project’s pom.xml and add the following dependency. Double-check the version number against the pom.xml in the cloned repository (it’s likely 1.0.0):
    <dependency>
        <groupId>com.github.bvanalderweireldt</groupId>
        <artifactId>concurrent-unique-queue</artifactId>
        <version>1.0.0</version>
    </dependency>
    
  • Finally, refresh your Maven dependencies in IntelliJ (click the refresh icon in the right-side Maven panel) — you’ll now be able to import and use the queue in your code.
Option 2: Use JitPack to Pull & Build Directly from GitHub

If you don’t want to clone and build locally, you can use JitPack, a service that builds GitHub repositories on-demand and serves them as Maven dependencies:

  • Add the JitPack repository to your project’s pom.xml (inside the <project> tag):
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    
  • Add the dependency for the library. You can use the branch name (like master), a specific tag (if the repo has them), or a commit hash for stability:
    <dependency>
        <groupId>com.github.bvanalderweireldt</groupId>
        <artifactId>concurrent-unique-queue</artifactId>
        <version>master</version>
    </dependency>
    
  • Refresh your Maven dependencies in IntelliJ, and JitPack will handle pulling, building, and serving the library for you.
Quick Test to Verify Setup

Once you’ve added the dependency, you can test it with a simple snippet to make sure everything works:

import com.github.bvanalderweireldt.concurrent.uniquequeue.ConcurrentUniqueQueue;

public class QueueTest {
    public static void main(String[] args) {
        ConcurrentUniqueQueue<String> uniqueQueue = new ConcurrentUniqueQueue<>();
        
        uniqueQueue.add("first-item");
        uniqueQueue.add("first-item"); // This won't be added — duplicates are rejected
        
        System.out.println("Queue size: " + uniqueQueue.size()); // Should print 1
    }
}

内容的提问来源于stack exchange,提问作者Leo Naylor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:25:56