I have configured neo4j and cassandra repositories separately with spring boot using spring-data. However, when I try to use two repositories in the same projects it doesn't work as expected.
This is my folder structure.
-----org.test.project
-----controller
BarController
FooController
-----models
-----dao
-----cassandra
BarDAO
FooDAO
-----neo4j
BarDAO
FooDAO
-----repositories
-----cassandra
BarRepository
FooRepository
-----neo
BarRepository
FooRepository
-----services
CassandraService (Has cassandra repositories @Autowired)
NeoService(Has neo repositories @Autowired)
TestApp.java
Note that all the repositories extend respective spring-datarepository with respective DAO.
When I run with this configurations it gives the following error.
Field airportRepository in org.test.project.TestApp required a bean of type 'org.test.project.repositories.cassandra.BarRepository' that could not be found.
I tried changing the Repository names. Then it started to work.
First question is can't we have same names as they are in different packages and start working
Though it started to work this time it gave an error in the authentication header.
org.neo4j.ogm.drivers.http.request.HttpRequestException: http://localhost:7474/db/data/transaction/commit: No authentication header supplied.
I have already added ogm.properties, the same way I did when I was using neo4j repositories only. But it seems they no longer get applied. So I added following into application.properties.
spring.data.neo4j.password=neo4j
spring.data.neo4j.username=neo4j
Second question is, how can I configure neo4j just as the same way I did only with neo4j? I have defined following in ogm.properties. How can I apply this into neo4j configurations?
#Driver, required
driver=org.neo4j.ogm.drivers.bolt.driver.BoltDriver
#URI of the Neo4j database, required. If no port is specified, the
#default port 7687 is used. Otherwise, a port can be specified with
#bolt://neo4j:password@localhost:1234
URI=bolt://neo4j:neo4j@localhost
#Connection pool size (the maximum number of sessions per URL),
#optional, defaults to 50
connection.pool.size=150
#Encryption level (TLS), optional, defaults to REQUIRED. Valid
#values are NONE,REQUIRED
encryption.level=NONE
With the above changes, now it is giving following error.
org.neo4j.ogm.exception.MappingException: No identity field found for class: org.rozzie.processor.models.dao.cassandra.FlightDAO
Note that a neo4j.ogm exception is thrown for the cassandra models. What is happening under the hood. How can I configure these two databases with spring boot in one project as above?