Skip to content

Commit

Permalink
Support Spring Boot 3 autoconfiguration (aerospike-community#171)
Browse files Browse the repository at this point in the history
* Support Spring Boot 3 autoconfiguration

* Upgrade to spring boot 3

* Upgrade to java 17

* Update GitHub Actions to support java 17

* Update tests for Spring Boot 3

* Update GitHub Actions step name to match with Java version

---------

Co-authored-by: Maksym Solomkin <[email protected]>
  • Loading branch information
solomkinmv and solomkinmv authored Feb 1, 2023
1 parent e66305b commit 2f6ced7
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
java-version: 17

# See: https://github.com/actions/cache/blob/master/examples.md#java---maven
- name: Maven cache and restore deps
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
java-version: 17
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish package
run: mvn --batch-mode deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.7.5</version>
<version>3.0.1</version>
</parent>

<groupId>com.aerospike</groupId>
Expand All @@ -32,7 +32,7 @@

<properties>
<revision>0.8.1</revision>
<java.version>1.8</java.version>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.aerospike.client.policy.QueryPolicy;
import com.aerospike.client.policy.WritePolicy;
import com.aerospike.client.reactor.AerospikeReactorClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -44,7 +45,7 @@
*
* @author Anastasiia Smirnova
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnClass(AerospikeClient.class)
@ConditionalOnProperty("spring.aerospike.hosts")
@EnableConfigurationProperties(AerospikeProperties.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.springframework.boot.autoconfigure.data.aerospike;

import org.springframework.beans.BeanUtils;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
Expand All @@ -23,7 +24,7 @@

import java.util.Collections;

@Configuration(proxyBeanMethods = false)
@AutoConfiguration
class AerospikeCommonDataConfiguration {

@Bean(name = "aerospikeFilterExpressionsBuilder")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.aerospike.client.AerospikeClient;
import com.aerospike.client.IAerospikeClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.aerospike.AerospikeAutoConfiguration;
Expand All @@ -36,7 +37,7 @@
* @author Igor Ermolenko
* @author Anastasiia Smirnova
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
// match only if we do not have reactive client
// we want sync context to be loaded when only sync client is on classpath
@ConditionalOnMissingClass("com.aerospike.client.reactor.AerospikeReactorClient")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.aerospike.client.IAerospikeClient;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -42,7 +43,7 @@
* @author Igor Ermolenko
* @author Anastasiia Smirnova
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
class AerospikeDataConfiguration {

@Bean(name = "aerospikeTemplate")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.data.aerospike;

import com.aerospike.client.reactor.AerospikeReactorClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.aerospike.AerospikeAutoConfiguration;
Expand All @@ -35,7 +36,7 @@
* @author Igor Ermolenko
* @author Anastasiia Smirnova
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnClass({AerospikeReactorClient.class, ReactiveAerospikeRepository.class, Flux.class})
@ConditionalOnSingleCandidate(AerospikeReactorClient.class)
@ConditionalOnProperty("spring.data.aerospike.namespace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.aerospike.client.reactor.AerospikeReactorClient;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -42,7 +43,7 @@
* @author Igor Ermolenko
* @author Anastasiia Smirnova
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
class AerospikeReactiveDataConfiguration {

@Bean(name = "reactiveAerospikeTemplate")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.data.aerospike;

import com.aerospike.client.reactor.AerospikeReactorClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -33,7 +34,7 @@
*
* @author Igor Ermolenko
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnClass({AerospikeReactorClient.class, ReactiveAerospikeRepository.class, Flux.class})
@ConditionalOnRepositoryType(store = "aerospike", type = RepositoryType.REACTIVE)
@ConditionalOnMissingBean(ReactiveAerospikeRepositoryFactoryBean.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.data.aerospike;

import com.aerospike.client.AerospikeClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -32,7 +33,7 @@
*
* @author Igor Ermolenko
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnClass({AerospikeClient.class, ReactiveAerospikeRepository.class})
@ConditionalOnRepositoryType(store = "aerospike", type = RepositoryType.IMPERATIVE)
@ConditionalOnMissingBean(AerospikeRepositoryFactoryBean.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
org.springframework.boot.autoconfigure.aerospike.AerospikeAutoConfiguration
org.springframework.boot.autoconfigure.data.aerospike.AerospikeDataAutoConfiguration
org.springframework.boot.autoconfigure.data.aerospike.AerospikeRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.aerospike.AerospikeReactiveDataAutoConfiguration
org.springframework.boot.autoconfigure.data.aerospike.AerospikeReactiveRepositoriesAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.data.aerospike.core.AerospikeTemplate;
import org.springframework.data.aerospike.core.ReactiveAerospikeTemplate;
import org.springframework.data.aerospike.mapping.AerospikeMappingContext;
import org.springframework.data.util.TypeInformation;
import org.springframework.test.util.ReflectionTestUtils;

import java.util.Set;
Expand Down Expand Up @@ -72,8 +73,7 @@ public void entityScanShouldSetInitialEntitySet() {
.withUserConfiguration(EntityScanConfiguration.class, AerospikeClientMockConfiguration.class)
.run(context -> {
AerospikeMappingContext mappingContext = context.getBean(AerospikeMappingContext.class);
Set<Class<?>> initialEntitySet = (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext, "initialEntitySet");
assertThat(initialEntitySet).containsOnly(City.class);
assertThat(mappingContext.getManagedTypes()).containsOnly(TypeInformation.of(City.class));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
import org.springframework.data.aerospike.core.AerospikeTemplate;
import org.springframework.data.aerospike.core.ReactiveAerospikeTemplate;
import org.springframework.data.aerospike.mapping.AerospikeMappingContext;
import org.springframework.test.util.ReflectionTestUtils;

import java.util.Set;
import org.springframework.data.util.TypeInformation;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.autoconfigure.data.aerospike.TestUtils.getField;
Expand Down Expand Up @@ -69,8 +67,7 @@ public void entityScanShouldSetInitialEntitySet() {
.withUserConfiguration(AerospikeTestConfigurations.EntityScanConfiguration.class, AerospikeClientMockConfiguration.class, MockReactiveIndexRefresher.class)
.run(context -> {
AerospikeMappingContext mappingContext = context.getBean(AerospikeMappingContext.class);
Set<Class<?>> initialEntitySet = (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext, "initialEntitySet");
assertThat(initialEntitySet).containsOnly(City.class);
assertThat(mappingContext.getManagedTypes()).containsOnly(TypeInformation.of(City.class));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.aerospike.client.cluster.Node;
import com.aerospike.client.policy.InfoPolicy;
import com.aerospike.client.policy.WritePolicy;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.data.aerospike.city.City;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
Expand All @@ -21,7 +22,7 @@

public class AerospikeTestConfigurations {

@Configuration(proxyBeanMethods = false)
@AutoConfiguration
public static class AerospikeClientMockConfiguration {

@Bean
Expand All @@ -34,7 +35,7 @@ public IAerospikeClient aerospikeClientMock() {

}

@Configuration(proxyBeanMethods = false)
@AutoConfiguration
public static class MockReactiveIndexRefresher {

@Bean
Expand All @@ -43,13 +44,13 @@ public ReactorIndexRefresher reactiveAerospikeIndexRefresher() {
}
}

@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@EntityScan("org.springframework.boot.autoconfigure.data.aerospike.city")
public static class EntityScanConfiguration {

}

@Configuration(proxyBeanMethods = false)
@AutoConfiguration
public static class CustomConversionsConfig {

@Bean(name = "aerospikeCustomConversions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.server.LocalServerPort;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
Expand Down Expand Up @@ -91,4 +91,4 @@ void savesAndFindsByLastName() {
;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.aerospike.example.sync;

import org.springframework.data.aerospike.repository.AerospikeRepository;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface SyncCustomerRepository extends AerospikeRepository<Customer, String> {
public interface SyncCustomerRepository extends AerospikeRepository<Customer, String>, CrudRepository<Customer, String> {
List<Customer> findByLastNameOrderByFirstNameAsc(String lastName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.server.LocalServerPort;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
Expand Down Expand Up @@ -91,4 +91,4 @@ void savesAndFindsByLastName() {
;
}

}
}

0 comments on commit 2f6ced7

Please sign in to comment.