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

前端 未结 1 1153
有刺的猬
有刺的猬 2021-01-21 07:49

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., -Do

相关标签:
1条回答
  • 2021-01-21 08:23

    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<>();
        }
    }
    
    0 讨论(0)
提交回复
热议问题