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.neo4j; 018 019import org.neo4j.ogm.session.Neo4jSession; 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.condition.ConditionalOnProperty; 026import org.springframework.context.annotation.Configuration; 027import org.springframework.context.annotation.Import; 028import org.springframework.data.neo4j.repository.Neo4jRepository; 029import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; 030import org.springframework.data.neo4j.repository.config.Neo4jRepositoryConfigurationExtension; 031import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryBean; 032 033/** 034 * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Neo4j 035 * Repositories. 036 * <p> 037 * Activates when there is no bean of type {@link Neo4jRepositoryFactoryBean} configured 038 * in the context, the Spring Data Neo4j {@link Neo4jRepository} type is on the classpath, 039 * the Neo4j client driver API is on the classpath, and there is no other configured 040 * {@link Neo4jRepository}. 041 * <p> 042 * Once in effect, the auto-configuration is the equivalent of enabling Neo4j repositories 043 * using the {@link EnableNeo4jRepositories} annotation. 044 * 045 * @author Dave Syer 046 * @author Oliver Gierke 047 * @author Josh Long 048 * @since 1.4.0 049 * @see EnableNeo4jRepositories 050 */ 051@Configuration 052@ConditionalOnClass({ Neo4jSession.class, Neo4jRepository.class }) 053@ConditionalOnMissingBean({ Neo4jRepositoryFactoryBean.class, 054 Neo4jRepositoryConfigurationExtension.class }) 055@ConditionalOnProperty(prefix = "spring.data.neo4j.repositories", name = "enabled", havingValue = "true", matchIfMissing = true) 056@Import(Neo4jRepositoriesAutoConfigureRegistrar.class) 057@AutoConfigureAfter(Neo4jDataAutoConfiguration.class) 058public class Neo4jRepositoriesAutoConfiguration { 059 060}