spring-projects / spring-projects/spring-boot
Provide auto-configuration for Liquibase with NoSQL databases
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 81.5k
- Forks
- 42.7k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
Description
Spring Boot version is 3.1.4.
Reproducer (ignore the README title, the initial scope of the reproducer is unrelated to this issue)
git clone git@github.com:fbiville/liquibase-neo4j-issue-479.git -b liquibase-only-props
docker run --rm \
--env NEO4J_AUTH='neo4j/letmein!' \
--env NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
--publish=7687:7687 \
--health-cmd "cypher-shell -u neo4j -p 'letmein!' 'RETURN 1'" \
--health-interval 5s \
--health-timeout 5s \
--health-retries 5 \
neo4j:5-enterprise
mvn spring-boot:run --file liquibase-neo4j-issue-479/pom.xml
Description
I believed (maybe wrongly so) that:
- having
spring-boot-starter,liquibase-core(andliquibase-neo4j) on the classpath - defining the configuration below
would theoretically be enough to run Liquibase:
spring:
liquibase:
driver-class-name: liquibase.ext.neo4j.database.jdbc.Neo4jDriver
change-log: classpath:changeLog.xml
url: jdbc:neo4j:neo4j://example.com
user: neo4j
password: *********
That is however not the case in practice.
First, I have to add spring-jdbc to the classpath, as org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration.LiquibaseConfiguration requires it (via @ConditionalOnClass(ConnectionCallback.class)).
But when I do that, here is what I get:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
The quick fix would be move most of the properties under the spring.datasource namespace.
However, this is a bad idea, at the very least in the case of the Neo4j extension.
Indeed, liquibase.ext.neo4j.database.jdbc.Neo4jDriver is a JDBC implementation specifically created for Liquibase purposes: only the required subset of all the JDBC APIs are implemented, and Liquibase only uses a single connection per execution - which eliminates a lot of complexity that would arise in generic JDBC implementations.
In other words, the extension does NOT provide a generic JDBC implementation .
Configuring a Datasource with spring.datasource could lead to that data source being used outside Liquibase, thus exercising the aforementioned implementation that is not designed for general use.
I believe some other Liquibase extensions provide their own limited JDBC implementation as well (at least Mongo iirc), so it is very likely they would suffer from the same issue.
Is there a way to make the above configuration sufficient for executing Liquibase? It looks like it should be.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration.LiquibaseConfiguration and the linked liquibase-neo4j-issue-479 reproducer, including its Maven setup. Check how the supplied spring.liquibase properties interact with the spring-jdbc and DataSource conditions; done means the shown configuration can execute Liquibase for the NoSQL extension without configuring a general-purpose DataSource.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100