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

别等时光非礼了梦想. 提交于 2019-12-02 00:17:48

问题


Been trying to get the WrappingNeoServerBootstrapper to start the Neo4j WebAdmin interface on 0.0.0.0 instead of localhost. Tried everything form specifying JAVA_OPTS (E.g., -Dorg.neo4j.server.webserver.address=0.0.0.0), to passing my own Config in the second constructor argument of WrappingNeoServerBootstrapper - but it always listens on localhost. Hoping someone has a solutions or an example. Here is my Spring config - back to basics. Thanks in advance.

<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase" destroy-method="shutdown">
    <constructor-arg index="0" value="${com.calendr.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="serverWrapper" class="org.neo4j.server.WrappingNeoServerBootstrapper" init-method="start" destroy-method="stop">
     <constructor-arg ref="graphDatabaseService"/>
</bean>

回答1:


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<>();
    }
}


来源:https://stackoverflow.com/questions/13432934/spring-data-neo4j-how-to-get-wrappingneoserverbootstrapper-to-listen-on-0-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!