Spring boot project uses spring-data-neo4j to connect with neo4j. It can start and access the database normally when running locally all the time. If you write dockerfile well and run on the server with docker compose, you will report an error, such as:
Caused by: java.lang.NullPointerException: null
at org.neo4j.ogm.MetaData.entityType(MetaData.java:280)
The reasons are as follows:
https://github.com/spring-projects/spring-boot/issues/6709
stay pom.xml To solve the problem, add dependency to
<!--Not adding this package to run in docker will report an error-->
<!--https://github.com/spring-guides/gs-accessing-data-neo4j/issues/19-->
<dependency>
<groupId>io.github.lukehutch</groupId>
<artifactId>fast-classpath-scanner</artifactId>
<version>3.1.13</version>
</dependency>