Merge pull request #8843 from herau:neo4j-auto-index-configuration
* pr/8843: Polish "Support of Neo4j auto-index configuration" Support of Neo4j auto-index configuration
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.data.neo4j;
|
||||
|
||||
import org.neo4j.ogm.config.AutoIndexMode;
|
||||
import org.neo4j.ogm.config.Configuration;
|
||||
import org.neo4j.ogm.config.Configuration.Builder;
|
||||
|
||||
@@ -31,6 +32,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Stephane Nicoll
|
||||
* @author Michael Hunger
|
||||
* @author Vince Bickers
|
||||
* @author Aurélien Leboulanger
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.data.neo4j")
|
||||
@@ -59,6 +61,11 @@ public class Neo4jProperties implements ApplicationContextAware {
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Auto index mode.
|
||||
*/
|
||||
private AutoIndexMode autoIndex = AutoIndexMode.NONE;
|
||||
|
||||
private final Embedded embedded = new Embedded();
|
||||
|
||||
private ClassLoader classLoader = Neo4jProperties.class.getClassLoader();
|
||||
@@ -87,6 +94,14 @@ public class Neo4jProperties implements ApplicationContextAware {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public AutoIndexMode getAutoIndex() {
|
||||
return this.autoIndex;
|
||||
}
|
||||
|
||||
public void setAutoIndex(AutoIndexMode autoIndex) {
|
||||
this.autoIndex = autoIndex;
|
||||
}
|
||||
|
||||
public Embedded getEmbedded() {
|
||||
return this.embedded;
|
||||
}
|
||||
@@ -116,6 +131,7 @@ public class Neo4jProperties implements ApplicationContextAware {
|
||||
if (this.username != null && this.password != null) {
|
||||
builder.credentials(this.username, this.password);
|
||||
}
|
||||
builder.autoIndex(this.getAutoIndex().getName());
|
||||
}
|
||||
|
||||
private void configureUriWithDefaults(Builder builder) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.net.URLClassLoader;
|
||||
import com.hazelcast.util.Base64;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.neo4j.ogm.config.AutoIndexMode;
|
||||
import org.neo4j.ogm.config.Configuration;
|
||||
import org.neo4j.ogm.config.Credentials;
|
||||
|
||||
@@ -106,6 +107,20 @@ public class Neo4jPropertiesTests {
|
||||
assertCredentials(configuration, "user", "secret");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoIndexNoneByDefault() {
|
||||
Neo4jProperties properties = load(true);
|
||||
Configuration configuration = properties.createConfiguration();
|
||||
assertThat(configuration.getAutoIndex()).isEqualTo(AutoIndexMode.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoIndexCanBeConfigured() {
|
||||
Neo4jProperties properties = load(true, "spring.data.neo4j.auto-index=validate");
|
||||
Configuration configuration = properties.createConfiguration();
|
||||
assertThat(configuration.getAutoIndex()).isEqualTo(AutoIndexMode.VALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void embeddedModeDisabledUseBoltUri() {
|
||||
Neo4jProperties properties = load(true,
|
||||
|
||||
@@ -613,6 +613,7 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.data.redis.repositories.enabled=true # Enable Redis repositories.
|
||||
|
||||
# NEO4J ({sc-spring-boot-autoconfigure}/neo4j/Neo4jProperties.{sc-ext}[Neo4jProperties])
|
||||
spring.data.neo4j.auto-index=none # Auto index mode.
|
||||
spring.data.neo4j.embedded.enabled=true # Enable embedded mode if the embedded driver is available.
|
||||
spring.data.neo4j.open-in-view=false # Register OpenSessionInViewInterceptor. Binds a Neo4j Session to the thread for the entire processing of the request.
|
||||
spring.data.neo4j.password= # Login password of the server.
|
||||
|
||||
Reference in New Issue
Block a user