Remove Spring Data Solr support
In preparation to the upgrade to Spring Data 2021.0, this commit removes auto-configuration for Spring Data Solr. Closes gh-24939
This commit is contained in:
parent
287edfba6e
commit
012a199773
|
@ -69,6 +69,7 @@ dependencies {
|
|||
optional("org.apache.commons:commons-dbcp2")
|
||||
optional("org.apache.kafka:kafka-clients")
|
||||
optional("org.apache.kafka:kafka-streams")
|
||||
optional("org.apache.solr:solr-solrj")
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-core")
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-el")
|
||||
optional("org.apache.tomcat:tomcat-jdbc")
|
||||
|
@ -99,7 +100,6 @@ dependencies {
|
|||
optional("org.springframework.data:spring-data-mongodb")
|
||||
optional("org.springframework.data:spring-data-redis")
|
||||
optional("org.springframework.data:spring-data-elasticsearch")
|
||||
optional("org.springframework.data:spring-data-solr")
|
||||
optional("org.springframework.integration:spring-integration-core")
|
||||
optional("org.springframework.kafka:spring-kafka")
|
||||
optional("org.springframework.security:spring-security-config")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,6 @@ import org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoCo
|
|||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
||||
|
@ -80,9 +79,8 @@ class WebEndpointsAutoConfigurationIntegrationTests {
|
|||
Neo4jRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class,
|
||||
MongoReactiveAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class,
|
||||
RepositoryRestMvcAutoConfiguration.class, HazelcastAutoConfiguration.class,
|
||||
ElasticsearchDataAutoConfiguration.class, SolrRepositoriesAutoConfiguration.class,
|
||||
SolrAutoConfiguration.class, RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class,
|
||||
MetricsAutoConfiguration.class })
|
||||
ElasticsearchDataAutoConfiguration.class, SolrAutoConfiguration.class, RedisAutoConfiguration.class,
|
||||
RedisRepositoriesAutoConfiguration.class, MetricsAutoConfiguration.class })
|
||||
@SpringBootConfiguration
|
||||
static class WebEndpointTestApplication {
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ dependencies {
|
|||
optional("javax.cache:cache-api")
|
||||
optional("javax.jms:javax.jms-api")
|
||||
optional("net.sf.ehcache:ehcache")
|
||||
optional("org.apache.solr:solr-solrj")
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-core")
|
||||
optional("org.aspectj:aspectjweaver")
|
||||
optional("org.eclipse.jetty:jetty-server")
|
||||
|
@ -60,7 +61,6 @@ dependencies {
|
|||
optional("org.springframework.data:spring-data-mongodb")
|
||||
optional("org.springframework.data:spring-data-redis")
|
||||
optional("org.springframework.data:spring-data-rest-webmvc")
|
||||
optional("org.springframework.data:spring-data-solr")
|
||||
optional("org.springframework.integration:spring-integration-core")
|
||||
optional("org.springframework.security:spring-security-core")
|
||||
optional("org.springframework.security:spring-security-web")
|
||||
|
|
|
@ -124,7 +124,6 @@ dependencies {
|
|||
optional("org.springframework.data:spring-data-neo4j")
|
||||
optional("org.springframework.data:spring-data-r2dbc")
|
||||
optional("org.springframework.data:spring-data-redis")
|
||||
optional("org.springframework.data:spring-data-solr")
|
||||
optional("org.springframework.hateoas:spring-hateoas")
|
||||
optional("org.springframework.security:spring-security-acl")
|
||||
optional("org.springframework.security:spring-security-config")
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.springframework.boot.autoconfigure.data.solr;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.solr.repository.SolrRepository;
|
||||
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
|
||||
import org.springframework.data.solr.repository.config.SolrRepositoryConfigExtension;
|
||||
import org.springframework.data.solr.repository.support.SolrRepositoryFactoryBean;
|
||||
|
||||
/**
|
||||
* Enables auto configuration for Spring Data Solr repositories.
|
||||
* <p>
|
||||
* Activates when there is no bean of type {@link SolrRepositoryFactoryBean} found in
|
||||
* context, and both {@link SolrRepository} and {@link SolrClient} can be found on
|
||||
* classpath.
|
||||
* </p>
|
||||
* If active auto configuration does the same as
|
||||
* {@link EnableSolrRepositories @EnableSolrRepositories} would do.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass({ SolrClient.class, SolrRepository.class })
|
||||
@ConditionalOnMissingBean({ SolrRepositoryFactoryBean.class, SolrRepositoryConfigExtension.class })
|
||||
@ConditionalOnProperty(prefix = "spring.data.solr.repositories", name = "enabled", havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
@Import(SolrRepositoriesRegistrar.class)
|
||||
public class SolrRepositoriesAutoConfiguration {
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.springframework.boot.autoconfigure.data.solr;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport;
|
||||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
|
||||
import org.springframework.data.solr.repository.config.SolrRepositoryConfigExtension;
|
||||
|
||||
/**
|
||||
* {@link ImportBeanDefinitionRegistrar} used to auto-configure Spring Data Solr
|
||||
* repositories.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
class SolrRepositoriesRegistrar extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
return EnableSolrRepositories.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> getConfiguration() {
|
||||
return EnableSolrRepositoriesConfiguration.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RepositoryConfigurationExtension getRepositoryConfigurationExtension() {
|
||||
return new SolrRepositoryConfigExtension();
|
||||
}
|
||||
|
||||
@EnableSolrRepositories
|
||||
private static class EnableSolrRepositoriesConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for Spring Data SOLR.
|
||||
*/
|
||||
package org.springframework.boot.autoconfigure.data.solr;
|
|
@ -54,7 +54,6 @@ org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration,\
|
|||
org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveRepositoriesAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,\
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.springframework.boot.autoconfigure.data.alt.solr;
|
||||
|
||||
import org.springframework.boot.autoconfigure.data.solr.city.City;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
public interface CitySolrRepository extends Repository<City, String> {
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElasticsearchDbRepository;
|
||||
import org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository;
|
||||
import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbRepository;
|
||||
import org.springframework.boot.autoconfigure.data.alt.solr.CitySolrRepository;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
|
@ -162,7 +162,7 @@ class JpaRepositoriesAutoConfigurationTests {
|
|||
@EnableJpaRepositories(
|
||||
basePackageClasses = org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository.class,
|
||||
excludeFilters = { @Filter(type = FilterType.ASSIGNABLE_TYPE, value = CityMongoDbRepository.class),
|
||||
@Filter(type = FilterType.ASSIGNABLE_TYPE, value = CitySolrRepository.class) })
|
||||
@Filter(type = FilterType.ASSIGNABLE_TYPE, value = CityElasticsearchDbRepository.class) })
|
||||
@TestAutoConfigurationPackage(City.class)
|
||||
static class CustomConfiguration {
|
||||
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.springframework.boot.autoconfigure.data.solr;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.solr.CitySolrRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.data.solr.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.solr.city.CityRepository;
|
||||
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link SolrRepositoriesAutoConfiguration}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class SolrRepositoriesAutoConfigurationTests {
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@AfterEach
|
||||
void close() {
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultRepositoryConfiguration() {
|
||||
initContext(TestConfiguration.class);
|
||||
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
|
||||
assertThat(this.context.getBean(SolrClient.class)).isInstanceOf(HttpSolrClient.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoRepositoryConfiguration() {
|
||||
initContext(EmptyConfiguration.class);
|
||||
assertThat(this.context.getBean(SolrClient.class)).isInstanceOf(HttpSolrClient.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
|
||||
initContext(CustomizedConfiguration.class);
|
||||
assertThat(this.context.getBean(CitySolrRepository.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoConfigurationShouldNotKickInEvenIfManualConfigDidNotCreateAnyRepositories() {
|
||||
initContext(SortOfInvalidCustomConfiguration.class);
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
|
||||
.isThrownBy(() -> this.context.getBean(CityRepository.class));
|
||||
}
|
||||
|
||||
private void initContext(Class<?> configClass) {
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(configClass, SolrAutoConfiguration.class, SolrRepositoriesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@TestAutoConfigurationPackage(City.class)
|
||||
static class TestConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@TestAutoConfigurationPackage(EmptyDataPackage.class)
|
||||
static class EmptyConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@TestAutoConfigurationPackage(SolrRepositoriesAutoConfigurationTests.class)
|
||||
@EnableSolrRepositories(basePackageClasses = CitySolrRepository.class)
|
||||
static class CustomizedConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@TestAutoConfigurationPackage(SolrRepositoriesAutoConfigurationTests.class)
|
||||
// To not find any repositories
|
||||
@EnableSolrRepositories("foo.bar")
|
||||
static class SortOfInvalidCustomConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.springframework.boot.autoconfigure.data.solr.city;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.solr.core.mapping.Indexed;
|
||||
import org.springframework.data.solr.core.mapping.SolrDocument;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@SolrDocument(collection = "collection1")
|
||||
public class City {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@Indexed
|
||||
private String name;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.springframework.boot.autoconfigure.data.solr.city;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
public interface CityRepository extends Repository<City, String> {
|
||||
|
||||
Page<City> findByNameStartingWith(String name, Pageable page);
|
||||
|
||||
}
|
|
@ -206,7 +206,6 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
|
|||
"spring-data-neo4j-version": versionConstraints["org.springframework.data:spring-data-neo4j"],
|
||||
"spring-data-r2dbc-version": versionConstraints["org.springframework.data:spring-data-r2dbc"],
|
||||
"spring-data-rest-version": versionConstraints["org.springframework.data:spring-data-rest-core"],
|
||||
"spring-data-solr-version": versionConstraints["org.springframework.data:spring-data-solr"],
|
||||
"spring-framework-version": versionConstraints["org.springframework:spring-core"],
|
||||
"spring-kafka-version": versionConstraints["org.springframework.kafka:spring-kafka"],
|
||||
"spring-integration-version": versionConstraints["org.springframework.integration:spring-integration-core"],
|
||||
|
|
|
@ -79,8 +79,6 @@
|
|||
:spring-data-r2dbc-docs: https://docs.spring.io/spring-data/r2dbc/docs/{spring-data-r2dbc-version}/reference/html/
|
||||
:spring-data-redis: https://spring.io/projects/spring-data-redis
|
||||
:spring-data-rest-api: https://docs.spring.io/spring-data/rest/docs/{spring-data-rest-version}/api/org/springframework/data/rest
|
||||
:spring-data-solr: https://spring.io/projects/spring-data-solr
|
||||
:spring-data-solr-docs: https://docs.spring.io/spring-data/solr/docs/{spring-data-solr-version}/reference/html/
|
||||
:spring-framework: https://spring.io/projects/spring-framework
|
||||
:spring-framework-api: https://docs.spring.io/spring/docs/{spring-framework-version}/javadoc-api/org/springframework
|
||||
:spring-framework-docs: https://docs.spring.io/spring/docs/{spring-framework-version}/reference/html
|
||||
|
|
|
@ -4579,7 +4579,6 @@ Spring Data provides additional projects that help you access a variety of NoSQL
|
|||
* {spring-data-mongodb}[MongoDB]
|
||||
* {spring-data-neo4j}[Neo4J]
|
||||
* {spring-data-elasticsearch}[Elasticsearch]
|
||||
* {spring-data-solr}[Solr]
|
||||
* {spring-data-redis}[Redis]
|
||||
* {spring-data-gemfire}[GemFire] or {spring-data-geode}[Geode]
|
||||
* {spring-data-cassandra}[Cassandra]
|
||||
|
@ -4886,8 +4885,7 @@ include::{code-examples}/neo4j/Neo4jReactiveTransactionManagerExample.java[tag=c
|
|||
[[boot-features-solr]]
|
||||
=== Solr
|
||||
https://lucene.apache.org/solr/[Apache Solr] is a search engine.
|
||||
Spring Boot offers basic auto-configuration for the Solr 5 client library and the abstractions on top of it provided by https://github.com/spring-projects/spring-data-solr[Spring Data Solr].
|
||||
There is a `spring-boot-starter-data-solr` "`Starter`" for collecting the dependencies in a convenient way.
|
||||
Spring Boot offers basic auto-configuration for the Solr 5 client library.
|
||||
|
||||
|
||||
|
||||
|
@ -4918,18 +4916,6 @@ If you add your own `@Bean` of type `SolrClient`, it replaces the default.
|
|||
|
||||
|
||||
|
||||
[[boot-features-spring-data-solr-repositories]]
|
||||
==== Spring Data Solr Repositories
|
||||
Spring Data includes repository support for Apache Solr.
|
||||
As with the JPA repositories discussed earlier, the basic principle is that queries are automatically constructed for you based on method names.
|
||||
|
||||
In fact, both Spring Data JPA and Spring Data Solr share the same common infrastructure.
|
||||
You could take the JPA example from earlier and, assuming that `City` is now a `@SolrDocument` class rather than a JPA `@Entity`, it works in the same way.
|
||||
|
||||
IP: For complete details of Spring Data Solr, refer to the {spring-data-solr-docs}[reference documentation].
|
||||
|
||||
|
||||
|
||||
[[boot-features-elasticsearch]]
|
||||
=== Elasticsearch
|
||||
https://www.elastic.co/products/elasticsearch[Elasticsearch] is an open source, distributed, RESTful search and analytics engine.
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
plugins {
|
||||
id "org.springframework.boot.starter"
|
||||
}
|
||||
|
||||
description = "Starter for using the Apache Solr search platform with Spring Data Solr"
|
||||
|
||||
dependencies {
|
||||
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
|
||||
api("org.springframework.data:spring-data-solr") {
|
||||
exclude group: "commons-logging", module: "commons-logging"
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
plugins {
|
||||
id "java"
|
||||
id "org.springframework.boot.conventions"
|
||||
}
|
||||
|
||||
description = "Spring Boot Data Solr smoke test"
|
||||
|
||||
dependencies {
|
||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-solr"))
|
||||
|
||||
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.solr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.client.solrj.beans.Field;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.solr.core.geo.Point;
|
||||
import org.springframework.data.solr.core.mapping.SolrDocument;
|
||||
|
||||
@SolrDocument(collection = "collection1")
|
||||
public class Product {
|
||||
|
||||
@Id
|
||||
@Field
|
||||
private String id;
|
||||
|
||||
@Field
|
||||
private String name;
|
||||
|
||||
@Field
|
||||
private Double price;
|
||||
|
||||
@Field("cat")
|
||||
private List<String> category;
|
||||
|
||||
@Field("store")
|
||||
private Point location;
|
||||
|
||||
public Product() {
|
||||
}
|
||||
|
||||
public Product(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return this.price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public List<String> getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void setCategory(List<String> category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public Point getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public void setLocation(Point location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Product [id=" + this.id + ", name=" + this.name + ", price=" + this.price + ", category="
|
||||
+ this.category + ", location=" + this.location + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.solr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.solr.repository.SolrCrudRepository;
|
||||
|
||||
public interface ProductRepository extends SolrCrudRepository<Product, String> {
|
||||
|
||||
List<Product> findByNameStartingWith(String name);
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.solr;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleSolrApplication implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private ProductRepository repository;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
this.repository.deleteAll();
|
||||
|
||||
// insert some products
|
||||
this.repository.save(new Product("1", "Nintendo Entertainment System"));
|
||||
this.repository.save(new Product("2", "Sega Megadrive"));
|
||||
this.repository.save(new Product("3", "Sony Playstation"));
|
||||
|
||||
// fetch all
|
||||
System.out.println("Products found by findAll():");
|
||||
System.out.println("----------------------------");
|
||||
for (Product product : this.repository.findAll()) {
|
||||
System.out.println(product);
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// fetch a single product
|
||||
System.out.println("Products found with findByNameStartingWith('So'):");
|
||||
System.out.println("--------------------------------");
|
||||
for (Product product : this.repository.findByNameStartingWith("So")) {
|
||||
System.out.println(product);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SampleSolrApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.solr;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.core.NestedCheckedException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
class SampleSolrApplicationTests {
|
||||
|
||||
@Test
|
||||
void testDefaultSettings(CapturedOutput output) throws Exception {
|
||||
try {
|
||||
SampleSolrApplication.main(new String[0]);
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
if (serverNotRunning(ex)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
assertThat(output).contains("name=Sony Playstation");
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private boolean serverNotRunning(IllegalStateException ex) {
|
||||
NestedCheckedException nested = new NestedCheckedException("failed", ex) {
|
||||
};
|
||||
Throwable root = nested.getRootCause();
|
||||
if (root.getMessage().contains("Connection refused")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue