Spring Data Neo4j - How to get WrappingNeoServerBootstrapper to listen on 0.0.0.0

余生长醉 提交于 2019-12-01 23:41:35

I figured it out after reading through the Neo code. Here is my final working config.

<neo4j:config graphDatabaseService="graphDatabaseService"/>

<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase" destroy-method="shutdown">
    <constructor-arg index="0" value="${com.mycompany.neo4jDataDir}"/>
    <constructor-arg index="1">
        <map>
            <entry key="allow_store_upgrade" value="true"/>
            <entry key="enable_remote_shell" value="true"/>
        </map>
    </constructor-arg> 
</bean>

<bean id="config" class="com.mycompany.Neo4jServerConfig">
    <constructor-arg> 
        <map>
            <entry key="org.neo4j.server.webserver.address" value="0.0.0.0"/>
        </map>
    </constructor-arg>     
</bean>

<bean id="serverWrapper" class="org.neo4j.server.WrappingNeoServerBootstrapper" init-method="start" destroy-method="stop">
    <constructor-arg index="0" ref="graphDatabaseService"/>
    <constructor-arg index="1" ref="config"/>
</bean>

And here is the config class:

public class Neo4jServerConfig implements Configurator {

    private Configuration config;

    public Ne4jServerConfig(Map<String, String> config) {
        this.config = new MapConfiguration(config);
    }

    @Override
    public Configuration configuration() {
        return config; 
    }

    @Override
    public Map<String, String> getDatabaseTuningProperties() {
        return null;
    }

    @Override
    public Set<ThirdPartyJaxRsPackage> getThirdpartyJaxRsClasses() {
        return new HashSet<>();
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!