java - Spring-Data-Neo4j: org.springframework.beans.factory.NoUniqueBeanDefinitionException -
i trying configure spring-data-neo4j
example java based configuration. when trying run test case, following stack trace print. according exception that, transaction neo4jtemplate multiple transaction manager thought.
org.springframework.beans.factory.nouniquebeandefinitionexception: no qualifying bean of type [org.springframework.transaction.platformtransactionmanager] defined: expected single matching bean found 2: neo4jtransactionmanager,jtatransactionmanagerfactorybean @ org.springframework.beans.factory.support.defaultlistablebeanfactory.getbean(defaultlistablebeanfactory.java:332) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.getbean(defaultlistablebeanfactory.java:298) @ org.springframework.transaction.interceptor.transactionaspectsupport.determinetransactionmanager(transactionaspectsupport.java:354) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:256) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:95) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) @ com.sun.proxy.$proxy68.findbyschemapropertyvalue(unknown source) @ com.harmeetsingh13.repositorytest.nodepersistencetest.getobjectfromrepo(nodepersistencetest.java:49)
my neo4j java based configuration:
@configuration @enabletransactionmanagement @propertysource(value="classpath:properties/db.properties") @componentscan(basepackages = "com.harmeetsingh13.entities") @enableneo4jrepositories(basepackages = "com.harmeetsingh13.repository") public class neo4jconfig extends neo4jaspectconfiguration{ @resource private environment env; public neo4jconfig() { setbasepackage("com.harmeetsingh13.entities"); } @bean(name = "graphdatabaseservice") public graphdatabaseservice getgraphdatabaseservice(){ graphdatabasefactory databaseservice = new graphdatabasefactory(); return databaseservice.newembeddeddatabase(env.getproperty("db.store.directory")); } @autowired @bean(name = "jtatransactionmanagerfactorybean") public jtatransactionmanagerfactorybean neo4jtransactionmanagerfactorybean (graphdatabaseservice graphdatabaseservice) throws exception { jtatransactionmanagerfactorybean factorybean = new jtatransactionmanagerfactorybean(graphdatabaseservice); return factorybean; } @autowired @bean(name= {"neo4jtransactionmanager"}) public platformtransactionmanager gettransactionmanager (jtatransactionmanagerfactorybean jtatransactionmanagerfactorybean) throws exception { chainedtransactionmanager transactionmanager = new chainedtransactionmanager(jtatransactionmanagerfactorybean.getobject()); return transactionmanager; } }
my test case:
@runwith(springjunit4classrunner.class) @transactional(value = "neo4jtransactionmanager") @contextconfiguration(classes = neo4jconfig.class, loader = annotationconfigcontextloader.class) public class nodepersistencetest { @autowired private neo4jtemplate neo4jtemplate; @autowired private repositorymovie movierepo; @test @transactional public void persistmovie() { movie movie = new movie(); movie.setid(13l); movie.settitle("dark knight"); movie returnmovie = neo4jtemplate.save(movie); assertthat(returnmovie, notnullvalue()); } @test public void getobjectfromrepo() { movie movie = movierepo.findbyschemapropertyvalue("id", 13); assertthat(movie, notnullvalue()); } }
in test case, first test case run successfully, exception produce on second test case , our test case fail.
Comments
Post a Comment