与此斗争了一段时间,无论我使用什么弹簧/新版本组合,都无法克服这个异常。
任何帮助将不胜感激。
完整的堆栈跟踪:http: //pastebin.com/SDM7fsBA
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'organizationRepository':
Cannot resolve reference to bean 'neo4jTemplate' while setting bean property 'neo4jTemplate';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'io.trips.rest.WebAppInitializer$Neo4jConfig':
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:
Could not instantiate bean class [io.trips.rest.WebAppInitializer$Neo4jConfig$$EnhancerByCGLIB$$d147012]:
No default constructor found; nested exception is java.lang.NoSuchMethodException: io.trips.rest.WebAppInitializer$Neo4jConfig$$EnhancerByCGLIB$$d147012.<init>()
WebAppInitializer.java:
//@Import({JpaConfig.class, MongoConfig.class})
//@ImportResource("classpath:META-INF/spring/security-config.xml")
@Configuration
@Import({Neo4jConfig.class})
public static class AppConfig {
@Bean(initMethod = "loadData")
public Neo4jLoader dataLoader() {
return new Neo4jLoader();
}
}
//public class Neo4jRepositoryConfig extends Neo4jConfiguration {
@EnableTransactionManagement
@EnableNeo4jRepositories(basePackages = "io.trips.rest.neo4j")
@Configuration
public class Neo4jConfig extends Neo4jConfiguration {
static final String DB_PATH = "target/neo4j-test-db";
@Bean //(destroyMethod = "shutdown")
public EmbeddedGraphDatabase graphDatabaseService() throws IOException {
FileUtils.deleteRecursively(new File(DB_PATH));
return new EmbeddedGraphDatabase(DB_PATH);
}
@Bean
public Neo4jTemplate neo4jTemplate() throws IOException {
return new Neo4jTemplate(graphDatabaseService());
}
@Bean
public Neo4jMappingContext neo4jMappingContext() {
return new Neo4jMappingContext();
}
@Bean
public JtaTransactionManagerFactoryBean transactionManager() throws Exception {
return new JtaTransactionManagerFactoryBean(graphDatabaseService());
}
@Bean
public Neo4jExceptionTranslator exceptionTranslator() {
return new Neo4jExceptionTranslator();
}
/**
@Bean(initMethod = "loadData")
public Neo4jLoader neo4jLoader() {
return new Neo4jLoader();
}
*/
}}
Organization.java(一个节点)
@NodeEntity
public class Organization {
@GraphId
private Long id;
//@Indexed(unique = true, indexName = "Geo")
String name;
}
组织存储库
package io.trips.rest.neo4j;
import org.springframework.data.neo4j.repository.GraphRepository;
public interface OrganizationRepository extends GraphRepository<Organization> {
}
Pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.2.2.RELEASE</spring.version>
<spring.security.version>3.2.0.M1</spring.security.version>
<springdata-jpa.version>1.3.1.RELEASE</springdata-jpa.version>
<springdata-neo4j.version>2.2.0.RELEASE</springdata-neo4j.version>
<springdata-rest-webmvc.version>1.1.0.M1</springdata-rest-webmvc.version>
<jackson.version>2.1.2</jackson.version>
<slf4j.version>1.7.2</slf4j.version>
</properties>
这是一个完整的堆栈跟踪: