安装

APOC Extended 可以通过以下部分所述的方法之一进行下载。

Neo4j 服务器

由于 APOC 依赖于 Neo4j 的内部 API,因此您需要使用与您的 Neo4j 安装版本匹配的 APOC 版本

APOC 使用一致的版本编号方案:<neo4j-version>.<apoc> 版本。版本号末尾的 <apoc> 部分会随着每次 APOC 发布而递增。

请确保 Neo4j 和 APOC 的前两位版本号一致

请前往此处获取所有 APOC Extended 版本,并下载二进制 jar 文件放入您的 $NEO4J_HOME/plugins 文件夹中。

将 jar 文件移动到插件文件夹后,您必须通过 neo4j restart 重启 Neo4j。

版本兼容性矩阵

APOC 使用一致的版本编号方案:<neo4j-version>.<apoc> 版本。版本号末尾的 <apoc> 部分会随着每次 APOC 发布而递增。

版本兼容性矩阵说明了 Neo4j 版本与 APOC 版本之间的映射关系

apoc 版本 neo4j 版本

2025.10.0

2025.10.0 (2025.10.x)

2025.09.0

2025.09.0 (2025.09.x)

2025.08.0

2025.08.0 (2025.08.x)

2025.07.0

2025.07.0 (2025.07.x)

2025.06.0

2025.06.0 (2025.06.x)

2025.05.0

2025.05.0 (2025.05.x)

2025.04.0

2025.04.0 (2025.04.x)

2025.03.0

2025.03.0 (2025.03.x)

2025.02.0

2025.02.0 (2025.02.x)

2025.01.0

2025.01.0 (2025.01.x)

5.26.0

5.26.0 (5.26.x)

5.25.0

5.25.0 (5.25.x)

5.24.0

5.24.0 (5.24.x)

5.23.0

5.23.0 (5.23.x)

5.22.0

5.22.0 (5.22.x)

5.21.0

5.21.0 (5.21.x)

5.20.0

5.20.0 (5.20.x)

5.19.0

5.19.0 (5.19.x)

5.18.0

5.18.0 (5.18.x)

5.17.1

5.17.0 (5.17.x)

5.16.0

5.16.0 (5.16.x)

5.15.0

5.15.0 (5.15.x)

5.14.0

5.14.0 (5.14.x)

5.13.0

5.13.0 (5.13.x)

5.12.0

5.12.0 (5.12.x)

5.11.0

5.11.0 (5.11.x)

5.10.0

5.10.0 (5.10.x)

5.9.0

5.9.0 (5.9.x)

5.8.0

5.8.0 (5.8.x)

5.7.0

5.7.0 (5.7.x)

5.6.0

5.6.0 (5.6.x)

5.5.0

5.5.0 (5.5.x)

5.4.0

5.4.0 (5.4.x)

5.3.1

5.3.0 (5.3.x)

5.2.0

5.2.0 (5.2.x)

5.1.0

5.1.0 (5.1.x)

4.4.0.36

4.4.0 (4.4.x)

如果不慎放入了与 Neo4j 版本不兼容的 jar 文件,neo4j.log 中会出现类似如下的 log.warn 警告信息

The apoc version (<APOC_VERSION>) and the Neo4j DBMS versions [NEO4J_VERSION] are incompatible.
See the compatibility matrix in /labs/apoc/4.4/installation/ to see the correct version

Neo4j Desktop

APOC Extended 无法通过 Plugins 选项卡安装。现有的“APOC”框安装的是 APOC Core,即

desktop apoc

为了安装 APOC Extended,我们必须从此处下载兼容版本,并手动将其放入 $NEO4J_HOME/plugins 文件夹中。

Docker

APOC Extended 可通过 NEO4J_PLUGINS=apoc-extended 环境变量与 Neo4j Docker 镜像一起使用。

如果使用此环境变量,APOC Extended 插件将在运行时自动下载并配置。

此功能旨在方便在开发环境中使用 APOC,但不建议在生产环境中使用。

以下命令在 Docker 容器中运行 Neo4j {neo4j-version},并带有最新版本的 APOC Extended 库
docker run \
    -p 7474:7474 -p 7687:7687 \
    -v $PWD/data:/data -v $PWD/plugins:/plugins \
    --name neo4j-apoc \
    -e NEO4J_apoc_export_file_enabled=true \
    -e NEO4J_apoc_import_file_enabled=true \
    -e NEO4J_apoc_import_file_use__neo4j__config=true \
    -e NEO4J_PLUGINS=\[\"apoc-extended\"\] \
    neo4j:{neo4j-version}

这将仅安装 APOC Extended 库。如需同时下载 APOC Extended 和 APOC Core,请指定:-e NEO4J_PLUGINS=\[\"apoc\", \"apoc-extended\"\]。有关 APOC Core 的文档,请参见此处

运行此命令后,输出中应显示以下两行

Fetching versions.json for Plugin 'apoc' from https://neo4j-contrib.github.io/neo4j-apoc-procedures/versions.json
Installing Plugin 'apoc' from https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/2025.10.0/2025.10.0-extended.jar to /plugins/apoc.jar

在生产环境中,我们应该下载与我们的 Neo4j 版本匹配的 APOC 发行版,将其复制到本地文件夹,并将其作为挂载在 /plugins 目录下的数据卷提供。

以下命令将 APOC Extended 库下载到 plugins 目录,然后将该文件夹挂载到 Neo4j Docker 容器中
mkdir plugins
pushd plugins
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/2025.10.0/apoc-2025.10.0-extended.jar
popd
docker run --rm -e NEO4J_AUTH=none -p 7474:7474 -v $PWD/plugins:/plugins -p 7687:7687 neo4j:2025.0

如果您想将自定义的 APOC 配置传递给 Docker 实例,可以使用环境变量,如下所示

docker run \
    -p 7474:7474 -p 7687:7687 \
    -v $PWD/data:/data -v $PWD/plugins:/plugins \
    --name neo4j-apoc \
    -e NEO4J_apoc_export_file_enabled=true \
    -e NEO4J_apoc_import_file_enabled=true \
    -e NEO4J_apoc_import_file_use__neo4j__config=true \
    neo4j

Maven 仓库

在 Maven 项目的 pom.xml 中,您可以从 Maven 仓库添加这两个依赖项

<dependency>
    <groupId>org.neo4j.procedure</groupId>
    <artifactId>apoc-extended</artifactId>
    <version>2025.10.0</version>
    <classifier>extended</classifier>
</dependency>

或者,您可以从此处下载 jar 文件并将其放入 plugin 文件夹中。

加载与解除限制

Extended APOC 库包含 150 多种函数和过程。

建议将所有这些内容加载到 DBMS 中,而应遵循最小权限原则。该原则规定,您只需加载执行查询所必需的函数和过程。

需要加载的过程和函数可以通过 $NEO4J_HOME/conf/neo4j.conf 中的 Neo4j 配置设置 dbms.security.procedures.allowlist 来指定。例如,要加载 apoc.load.csvapoc.cypher 包中的所有函数,请使用 dbms.security.procedures.allowlist=apoc.load.csv,apoc.cypher.*

请注意,如果安装了 APOC Core 插件,使用例如 apoc.cypher.* 也会同时加载 APOC Core 中的 apoc.cypher.* 过程/函数,以及可能使用相同包的其他插件。

该设置的默认值为 *。这意味着如果您没有明确为其赋值(或未赋值),则会加载所有 APOC 过程和函数,以及 plugins 目录下的其他潜在库。

出于安全考虑,使用内部 API 的过程和函数默认是禁用的。在这种情况下,也建议遵循最小权限原则,仅解除您确定要使用的那些过程和函数的限制。可以使用 $NEO4J_HOME/conf/neo4j.conf 中的 Neo4j 配置设置 dbms.security.procedures.unrestricted 来解除过程和函数的限制。例如,如果您需要解除 apoc.ttl.expireapoc.ttl.expireIn 的限制,请使用:dbms.security.procedures.unrestricted=apoc.ttl.expire,apoc.ttl.expireIn

在使用 Neo4j Docker 容器时,若要解除整个 APOC 函数和过程包的限制,您需要修改 Docker 环境变量。例如,如果您需要添加完整的 apoc.custom 包,请在 docker run …​ 命令中添加 -e NEO4J_dbms_security_procedures_unrestricted=apoc.custom.\\\*。三个反斜杠是防止通配符展开所必需的。

请注意,如果您安装了 APOC Core,dbms.security.procedures.allowlist 的规则同样适用,因此设置 dbms.security.procedures.unrestricted=package.name.* 将同时解除 Extended 和 Core 过程/函数的限制。

© . This site is unofficial and not affiliated with Neo4j, Inc.