You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2021/04/19 07:47:21 UTC
[ignite-extensions] branch master updated: IGNITE-13029 Support
Spring Data repositories initialization with Spring Boot auto-starter -
Fixes #41.
This is an automated email from the ASF dual-hosted git repository.
sergeychugunov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new 7a26b06 IGNITE-13029 Support Spring Data repositories initialization with Spring Boot auto-starter - Fixes #41.
7a26b06 is described below
commit 7a26b06dbe7db240eb3021e224b94990325bff8a
Author: dorozhkin-sg <sg...@gmail.com>
AuthorDate: Mon Apr 19 10:05:10 2021 +0300
IGNITE-13029 Support Spring Data repositories initialization with Spring Boot auto-starter - Fixes #41.
Signed-off-by: Sergey Chugunov <se...@gmail.com>
---
modules/spring-boot-autoconfigure-ext/pom.xml | 14 +++
.../autoconfigure/IgniteAutoConfiguration.java | 2 +-
.../IgniteRepositoryAutoConfiguration.java | 56 +++++++++++
...niteRepositoriesAutoConfigurationRegistrar.java | 54 ++++++++++
.../boot/autoconfigure/data/package-info.java | 22 ++++
.../src/main/resources/META-INF/spring.factories | 3 +-
.../IgniteRepositoriesAutoconfigureTest.java | 86 ++++++++++++++++
.../misc/DefaultTestConfigutation.java | 39 ++++++++
.../boot/autoconfigure/misc/ObjectRepository.java | 29 ++++++
.../pom.xml | 14 +++
.../IgniteClientAutoConfiguration.java | 2 +-
.../IgniteClientRepositoryAutoConfiguration.java | 53 ++++++++++
...niteRepositoriesAutoConfigurationRegistrar.java | 54 ++++++++++
.../boot/autoconfigure/data/package-info.java | 22 ++++
.../src/main/resources/META-INF/spring.factories | 3 +-
.../IgniteClientRepositoriesAutoconfigureTest.java | 111 +++++++++++++++++++++
.../boot/autoconfigure/misc/ObjectRepository.java | 29 ++++++
parent/pom.xml | 1 +
18 files changed, 590 insertions(+), 4 deletions(-)
diff --git a/modules/spring-boot-autoconfigure-ext/pom.xml b/modules/spring-boot-autoconfigure-ext/pom.xml
index f973f6f..7eb0eb4 100644
--- a/modules/spring-boot-autoconfigure-ext/pom.xml
+++ b/modules/spring-boot-autoconfigure-ext/pom.xml
@@ -58,6 +58,20 @@
<dependency>
<groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring-data_2.2-ext</artifactId>
+ <version>${ignite.springdata.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-commons</artifactId>
+ <version>${spring.data-2.2.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
<artifactId>ignite-log4j</artifactId>
<version>${ignite.version}</version>
<scope>test</scope>
diff --git a/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteAutoConfiguration.java b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteAutoConfiguration.java
index 449f008..558ed63 100644
--- a/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteAutoConfiguration.java
+++ b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteAutoConfiguration.java
@@ -95,7 +95,7 @@ public class IgniteAutoConfiguration {
*/
@ConditionalOnBean(IgniteConfiguration.class)
@Bean
- public Ignite ignite(IgniteConfiguration cfg) {
+ public Ignite igniteInstance(IgniteConfiguration cfg) {
return Ignition.start(cfg);
}
}
diff --git a/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoryAutoConfiguration.java b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoryAutoConfiguration.java
new file mode 100644
index 0000000..8829d3a
--- /dev/null
+++ b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoryAutoConfiguration.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata22.repository.IgniteRepository;
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springdata22.repository.config.IgniteRepositoryConfigurationExtension;
+import org.apache.ignite.springdata22.repository.support.IgniteRepositoryFactoryBean;
+import org.apache.ignite.springframework.boot.autoconfigure.data.IgniteRepositoriesAutoConfigurationRegistrar;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+
+
+/**
+ * {@link EnableAutoConfiguration Auto-configuration} for Ignite Spring Data's Repositories.
+ * <p>
+ * Activates when there is a bean of type {@link org.apache.ignite.Ignite} configured in the
+ * context, the Ignite Spring Data {@link IgniteRepository} type is on the classpath,
+ * and there is no other, existing {@link IgniteRepository} configured.
+ * <p>
+ * Once in effect, the auto-configuration is the equivalent of enabling Ignite repositories
+ * using the {@link EnableIgniteRepositories @EnableIgniteRepositories} annotation.
+ * <p>
+ * This configuration class will activate <em>after</em> the Ignite node auto-configuration.
+ */
+@Configuration
+@ConditionalOnBean(Ignite.class)
+@ConditionalOnClass(IgniteRepository.class)
+@ConditionalOnMissingBean({IgniteRepositoryFactoryBean.class, IgniteRepositoryConfigurationExtension.class})
+@Import(IgniteRepositoriesAutoConfigurationRegistrar.class)
+@AutoConfigureAfter({IgniteAutoConfiguration.class})
+public class IgniteRepositoryAutoConfiguration {
+
+}
diff --git a/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/IgniteRepositoriesAutoConfigurationRegistrar.java b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/IgniteRepositoriesAutoConfigurationRegistrar.java
new file mode 100644
index 0000000..24b0992
--- /dev/null
+++ b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/IgniteRepositoriesAutoConfigurationRegistrar.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure.data;
+
+import java.lang.annotation.Annotation;
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springdata22.repository.config.IgniteRepositoryConfigurationExtension;
+import org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport;
+import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
+import org.springframework.data.repository.config.RepositoryConfigurationExtension;
+
+/**
+ * {@link ImportBeanDefinitionRegistrar} used to auto-configure Ignite Spring Data Repositories.
+ */
+public class IgniteRepositoriesAutoConfigurationRegistrar extends AbstractRepositoryConfigurationSourceSupport {
+
+ /** {@inheritDoc} */
+ @Override protected Class<? extends Annotation> getAnnotation() {
+ return EnableIgniteRepositories.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Class<?> getConfiguration() {
+ return EnableIgniteRepositoriesConfiguration.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected RepositoryConfigurationExtension getRepositoryConfigurationExtension() {
+ return new IgniteRepositoryConfigurationExtension();
+ }
+
+ /**
+ * The configuration class that will be used by Spring Boot as a template.
+ */
+ @EnableIgniteRepositories
+ private static class EnableIgniteRepositoriesConfiguration {
+
+ }
+}
diff --git a/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/package-info.java b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/package-info.java
new file mode 100644
index 0000000..1913e51
--- /dev/null
+++ b/modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Package includes configuration files needed for Ignite Spring Data autoconfiguration.
+ */
+package org.apache.ignite.springframework.boot.autoconfigure.data;
diff --git a/modules/spring-boot-autoconfigure-ext/src/main/resources/META-INF/spring.factories b/modules/spring-boot-autoconfigure-ext/src/main/resources/META-INF/spring.factories
index 1fc7d14..1e1184b 100644
--- a/modules/spring-boot-autoconfigure-ext/src/main/resources/META-INF/spring.factories
+++ b/modules/spring-boot-autoconfigure-ext/src/main/resources/META-INF/spring.factories
@@ -14,4 +14,5 @@
# limitations under the License.
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.ignite.springframework.boot.autoconfigure.IgniteAutoConfiguration
+org.apache.ignite.springframework.boot.autoconfigure.IgniteAutoConfiguration,\
+org.apache.ignite.springframework.boot.autoconfigure.IgniteRepositoryAutoConfiguration
diff --git a/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoriesAutoconfigureTest.java b/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoriesAutoconfigureTest.java
new file mode 100644
index 0000000..ed75f97
--- /dev/null
+++ b/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoriesAutoconfigureTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure;
+
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springframework.boot.autoconfigure.misc.DefaultTestConfigutation;
+import org.apache.ignite.springframework.boot.autoconfigure.misc.ObjectRepository;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests {@link IgniteRepositoryAutoConfiguration} feature. */
+@ExtendWith(SpringExtension.class)
+public class IgniteRepositoriesAutoconfigureTest {
+
+ /** Spring test application context. */
+ private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
+ .withUserConfiguration(DefaultTestConfigutation.class)
+ .withConfiguration(AutoConfigurations.of(IgniteAutoConfiguration.class, IgniteRepositoryAutoConfiguration.class));
+
+
+ /** Test default autoconfiguration */
+ @Test
+ public void testDefaultConfiguration() {
+ contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
+ assertThat(context).hasSingleBean(ObjectRepository.class);
+ });
+ }
+
+ /** Test configuration with @EnableIgniteRepositories */
+ @Test
+ public void testOverrideConfiguration() {
+ contextRunner.withUserConfiguration(OverrideConfiguration.class).run((context) -> {
+ assertThat(context).hasSingleBean(ObjectRepository.class);
+ });
+ }
+
+ /** Test configuration with @EnableIgniteRepositories and invalid base package */
+ @Test
+ public void testInvalidBasePackage() {
+ contextRunner.withUserConfiguration(InvalidConfiguration.class).run((context) -> {
+ assertThat(context).doesNotHaveBean(ObjectRepository.class);
+ });
+ }
+
+
+ /** */
+ @AutoConfigurationPackage
+ protected static class TestConfiguration {
+
+ }
+
+ /** */
+ @EnableIgniteRepositories
+ protected static class OverrideConfiguration {
+
+ }
+
+ /** */
+ @EnableIgniteRepositories(basePackages = "wrong.package")
+ protected static class InvalidConfiguration {
+
+ }
+
+
+}
diff --git a/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/DefaultTestConfigutation.java b/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/DefaultTestConfigutation.java
new file mode 100644
index 0000000..3d73da1
--- /dev/null
+++ b/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/DefaultTestConfigutation.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure.misc;
+
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Default Ignite configuration for Ignite Spring Data autoconfigure test
+ */
+@Configuration
+public class DefaultTestConfigutation {
+
+ /** */
+ @Bean
+ public IgniteConfiguration igniteConfiguration() {
+ return new IgniteConfiguration()
+ .setCacheConfiguration(new CacheConfiguration<Long, Object>().setName("objectCache"))
+ .setIgniteInstanceName("test-name")
+ .setConsistentId("test-id");
+ }
+}
diff --git a/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/ObjectRepository.java b/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/ObjectRepository.java
new file mode 100644
index 0000000..0e68033
--- /dev/null
+++ b/modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/ObjectRepository.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure.misc;
+
+import org.apache.ignite.springdata22.repository.IgniteRepository;
+import org.apache.ignite.springdata22.repository.config.RepositoryConfig;
+
+/**
+ * Test repository.
+ */
+@RepositoryConfig(cacheName = "objectCache")
+public interface ObjectRepository extends IgniteRepository<Object, Integer> {
+
+}
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/pom.xml b/modules/spring-boot-thin-client-autoconfigure-ext/pom.xml
index f5a225c..8c376c3 100644
--- a/modules/spring-boot-thin-client-autoconfigure-ext/pom.xml
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/pom.xml
@@ -59,6 +59,20 @@
<dependency>
<groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring-data_2.2-ext</artifactId>
+ <version>${ignite.springdata.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-commons</artifactId>
+ <version>${spring.data-2.2.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
<artifactId>ignite-log4j</artifactId>
<version>${ignite.version}</version>
<scope>test</scope>
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientAutoConfiguration.java b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientAutoConfiguration.java
index fddb8a3..e7ecad4 100644
--- a/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientAutoConfiguration.java
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientAutoConfiguration.java
@@ -78,7 +78,7 @@ public class IgniteClientAutoConfiguration {
@ConditionalOnMissingBean
@Bean
@ConfigurationProperties(prefix = IGNITE_CLIENT_PROPS_PREFIX)
- public ClientConfiguration clientConfiguration(IgniteClientConfigurer configurer) {
+ public ClientConfiguration igniteCfg(IgniteClientConfigurer configurer) {
ClientConfiguration cfg = new ClientConfiguration();
configurer.accept(cfg);
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientRepositoryAutoConfiguration.java b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientRepositoryAutoConfiguration.java
new file mode 100644
index 0000000..1f54feb
--- /dev/null
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientRepositoryAutoConfiguration.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure;
+
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.springdata22.repository.IgniteRepository;
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springdata22.repository.config.IgniteRepositoryConfigurationExtension;
+import org.apache.ignite.springdata22.repository.support.IgniteRepositoryFactoryBean;
+import org.apache.ignite.springframework.boot.autoconfigure.data.IgniteRepositoriesAutoConfigurationRegistrar;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+/**
+ * {@link EnableAutoConfiguration Auto-configuration} for Ignite Spring Data's Repositories.
+ * <p>
+ * Activates when there is a bean of type {@link IgniteClient} configured in the
+ * context, the Ignite Spring Data {@link IgniteRepository} type is on the classpath,
+ * and there is no other, existing {@link IgniteRepository} configured.
+ * <p>
+ * Once in effect, the auto-configuration is the equivalent of enabling Ignite repositories
+ * using the {@link EnableIgniteRepositories @EnableIgniteRepositories} annotation.
+ * <p>
+ * This configuration class will activate <em>after</em> the Ignite client auto-configuration.
+ */
+@Configuration
+@ConditionalOnBean(IgniteClient.class)
+@ConditionalOnClass(IgniteRepository.class)
+@ConditionalOnMissingBean({IgniteRepositoryFactoryBean.class, IgniteRepositoryConfigurationExtension.class})
+@Import(IgniteRepositoriesAutoConfigurationRegistrar.class)
+@AutoConfigureAfter({IgniteClientAutoConfiguration.class})
+public class IgniteClientRepositoryAutoConfiguration {
+}
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/IgniteRepositoriesAutoConfigurationRegistrar.java b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/IgniteRepositoriesAutoConfigurationRegistrar.java
new file mode 100644
index 0000000..24b0992
--- /dev/null
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/IgniteRepositoriesAutoConfigurationRegistrar.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure.data;
+
+import java.lang.annotation.Annotation;
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springdata22.repository.config.IgniteRepositoryConfigurationExtension;
+import org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport;
+import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
+import org.springframework.data.repository.config.RepositoryConfigurationExtension;
+
+/**
+ * {@link ImportBeanDefinitionRegistrar} used to auto-configure Ignite Spring Data Repositories.
+ */
+public class IgniteRepositoriesAutoConfigurationRegistrar extends AbstractRepositoryConfigurationSourceSupport {
+
+ /** {@inheritDoc} */
+ @Override protected Class<? extends Annotation> getAnnotation() {
+ return EnableIgniteRepositories.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Class<?> getConfiguration() {
+ return EnableIgniteRepositoriesConfiguration.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected RepositoryConfigurationExtension getRepositoryConfigurationExtension() {
+ return new IgniteRepositoryConfigurationExtension();
+ }
+
+ /**
+ * The configuration class that will be used by Spring Boot as a template.
+ */
+ @EnableIgniteRepositories
+ private static class EnableIgniteRepositoriesConfiguration {
+
+ }
+}
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/package-info.java b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/package-info.java
new file mode 100644
index 0000000..1913e51
--- /dev/null
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Package includes configuration files needed for Ignite Spring Data autoconfiguration.
+ */
+package org.apache.ignite.springframework.boot.autoconfigure.data;
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/src/main/resources/META-INF/spring.factories b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/resources/META-INF/spring.factories
index 7eb759b..b49fb76 100644
--- a/modules/spring-boot-thin-client-autoconfigure-ext/src/main/resources/META-INF/spring.factories
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/src/main/resources/META-INF/spring.factories
@@ -14,4 +14,5 @@
# limitations under the License.
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.ignite.springframework.boot.autoconfigure.IgniteClientAutoConfiguration
+org.apache.ignite.springframework.boot.autoconfigure.IgniteClientAutoConfiguration,\
+org.apache.ignite.springframework.boot.autoconfigure.IgniteClientRepositoryAutoConfiguration
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientRepositoriesAutoconfigureTest.java b/modules/spring-boot-thin-client-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientRepositoriesAutoconfigureTest.java
new file mode 100644
index 0000000..2be84ba
--- /dev/null
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteClientRepositoriesAutoconfigureTest.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.ClientConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springframework.boot.autoconfigure.misc.ObjectRepository;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests {@link IgniteClientRepositoryAutoConfiguration} feature. */
+@ExtendWith(SpringExtension.class)
+public class IgniteClientRepositoriesAutoconfigureTest {
+
+ /** Spring test application context. */
+ private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
+ .withPropertyValues("ignite-client.addresses=127.0.0.1:10801")
+ .withConfiguration(AutoConfigurations.of(IgniteClientAutoConfiguration.class, IgniteClientRepositoryAutoConfiguration.class));
+
+ /** Server node. */
+ private static Ignite node;
+
+ /** Test cache name */
+ private static final String CACHE_NAME = "objectCache";
+
+ /** */
+ @BeforeAll
+ public static void beforeClass() {
+ node = Ignition.start(new IgniteConfiguration()
+ .setClientConnectorConfiguration(
+ new ClientConnectorConfiguration().setPort(10801)));
+ node.createCache(CACHE_NAME);
+ }
+
+ /** */
+ @AfterAll
+ public static void afterClass() {
+ node.close();
+ }
+
+ /** Test default autoconfiguration */
+ @Test
+ public void testDefaultConfiguration() {
+ contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
+ assertThat(context).hasSingleBean(ObjectRepository.class);
+ });
+ }
+
+ /** Test configuration with @EnableIgniteRepositories */
+ @Test
+ public void testOverrideConfiguration() {
+ contextRunner.withUserConfiguration(OverrideConfiguration.class).run((context) -> {
+ assertThat(context).hasSingleBean(ObjectRepository.class);
+ });
+ }
+
+ /** Test configuration with @EnableIgniteRepositories and invalid base package */
+ @Test
+ public void testInvalidBasePackage() {
+ contextRunner.withUserConfiguration(InvalidConfiguration.class).run((context) -> {
+ assertThat(context).doesNotHaveBean(ObjectRepository.class);
+ });
+ }
+
+
+ /** */
+ @AutoConfigurationPackage
+ protected static class TestConfiguration {
+
+ }
+
+ /** */
+ @EnableIgniteRepositories
+ protected static class OverrideConfiguration {
+
+ }
+
+ /** */
+ @EnableIgniteRepositories(basePackages = "wrong.package")
+ protected static class InvalidConfiguration {
+
+ }
+
+
+}
diff --git a/modules/spring-boot-thin-client-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/ObjectRepository.java b/modules/spring-boot-thin-client-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/ObjectRepository.java
new file mode 100644
index 0000000..0e68033
--- /dev/null
+++ b/modules/spring-boot-thin-client-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/misc/ObjectRepository.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springframework.boot.autoconfigure.misc;
+
+import org.apache.ignite.springdata22.repository.IgniteRepository;
+import org.apache.ignite.springdata22.repository.config.RepositoryConfig;
+
+/**
+ * Test repository.
+ */
+@RepositoryConfig(cacheName = "objectCache")
+public interface ObjectRepository extends IgniteRepository<Object, Integer> {
+
+}
diff --git a/parent/pom.xml b/parent/pom.xml
index 785559e..a94c273 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -37,6 +37,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<ignite.version>2.11.0-SNAPSHOT</ignite.version>
+ <ignite.springdata.version>1.0.0-SNAPSHOT</ignite.springdata.version>
<ignite.edition>apache-ignite</ignite.edition>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>