问题描述
需要把neo4j中创建好的本体(结点和关系)导出至json格式,运行如下代码时出错。
备注:neo4j桌面版j和apoc plugin版本都是5.20.0。
CALL apoc.export.json.all("yes.json")
第一个遇到的问题
Failed to invoke procedure: Caused by: java.lang.RuntimeException: Export to files not enabled, please set apoc.export.file.enabled=true in your apoc.conf.
Otherwise, if you are running in a cloud environment without filesystem access, use the {stream:true} config and null as a 'file' parameter to stream the export back to your client.
Note that the stream mode cannot be used with the apoc.export.xls.* procedures.
参考该老师的方法,采取了如下措施:修改setting中的内容。
dbms.security.procedures.unrestricted=apoc.*
dbms.security.procedures.allowlist=apoc.*
满怀信心,觉得又没问题了,结果又遇到了第二个问题。
中间还遇到一个问题,桌面版是没有apoc.conf的,不要被apoc官方文档骗了,就算你自己创建了并添加apoc.export.file.enabled=true apoc.import…file.enabled=true也是没用的。(雷中雷)加到DBMS的setting会直接导致数据库无法启动!!!!!(社区版不确定,请注意看版本叭)
第二个遇到的问题
Failed to invoke procedure `apoc.export.json.all`: Caused by: org.apache.commons.configuration2.ex.ConversionException: Key 'apoc.export.file.enabled' cannot be converted to class java.lang.Boolean. Value is: '[true, true]'.
啊啊啊啊!!!!崩溃状态!!
注意了!!!还是setting的问题,
请把setting改成这样:
其中1是apoc安装以后系统自带的,我之前给它注释掉了,加了2和3报错如问题二。所以解决方案其实就是默认的1不要动,没有就加上;然后加上3,问题就解决了!!
第三个问题
重新建立了一个project,我也按照第二个问题的解决方式做了,然后如下:
但是依旧报错,让我去改apoc.conf,青天大老爷,你告诉我哪里找。仔细对比了下之前能导出的那个project,盲生我发现了华点。
终极解决方案,请直接复制
dbms.security.procedures.unrestricted=jwt.security.*,apoc.*,gds.*
dbms.security.procedures.allowlist=apoc.*
总结
值得做的:遇事不决,多看看setting!!!
不要做的:
不要加奇奇怪怪的东西,请参考问题一末尾
官方语法以及说明:这里