001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure.data.mongo; 018 019import com.mongodb.reactivestreams.client.MongoClient; 020 021import org.springframework.boot.autoconfigure.AutoConfigureAfter; 022import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 023import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 024import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 025import org.springframework.boot.autoconfigure.data.ConditionalOnRepositoryType; 026import org.springframework.boot.autoconfigure.data.RepositoryType; 027import org.springframework.context.annotation.Configuration; 028import org.springframework.context.annotation.Import; 029import org.springframework.data.mongodb.repository.ReactiveMongoRepository; 030import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories; 031import org.springframework.data.mongodb.repository.config.ReactiveMongoRepositoryConfigurationExtension; 032import org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactoryBean; 033 034/** 035 * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Mongo Reactive 036 * Repositories. 037 * <p> 038 * Activates when there is no bean of type 039 * {@link org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactoryBean} 040 * configured in the context, the Spring Data Mongo {@link ReactiveMongoRepository} type 041 * is on the classpath, the ReactiveStreams Mongo client driver API is on the classpath, 042 * and there is no other configured {@link ReactiveMongoRepository}. 043 * <p> 044 * Once in effect, the auto-configuration is the equivalent of enabling Mongo repositories 045 * using the {@link EnableReactiveMongoRepositories} annotation. 046 * 047 * @author Mark Paluch 048 * @since 2.0.0 049 * @see EnableReactiveMongoRepositories 050 */ 051@Configuration 052@ConditionalOnClass({ MongoClient.class, ReactiveMongoRepository.class }) 053@ConditionalOnMissingBean({ ReactiveMongoRepositoryFactoryBean.class, 054 ReactiveMongoRepositoryConfigurationExtension.class }) 055@ConditionalOnRepositoryType(store = "mongodb", type = RepositoryType.REACTIVE) 056@Import(MongoReactiveRepositoriesAutoConfigureRegistrar.class) 057@AutoConfigureAfter(MongoReactiveDataAutoConfiguration.class) 058public class MongoReactiveRepositoriesAutoConfiguration { 059 060}