Spring Boot 1.5.8集成Liquibase启动时抛出NotWritablePropertyException
Troubleshooting Your Liquibase Setup with Spring Boot 1.5.8.RELEASE
Since you haven't shared the full exception stack trace, let's walk through the most common pitfalls and fixes for your configuration:
1. Check Dependency Compatibility & Conflicts
Spring Boot 1.5.8.RELEASE manages the Liquibase version automatically when you use compile('org.liquibase:liquibase-core') without specifying a version (this is the right approach). For this Boot version, the default Liquibase version is 3.5.3.
- Run
./gradlew dependenciesin your project root to verify the actual Liquibase version being pulled in. If another dependency is bringing in a conflicting version (newer or older), you'll need to exclude that conflicting dependency in yourbuild.gradle.
2. Validate Your Changelog File Path & Structure
Your config points to classpath:db/changelog.xml, so double-check:
- The file exists exactly at
src/main/resources/db/changelog.xml(paths are case-sensitive, especially on Linux/macOS). - The XML uses the correct schema for Liquibase 3.5.x. Your root node should look like this:
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> <!-- Your change sets go here --> </databaseChangeLog>
3. Fix Redundant Database Connection Configs
In Spring Boot 1.5.x, Liquibase automatically uses the credentials from your spring.datasource configuration—there's no need to repeat url, user, and password under the liquibase node. This duplication can cause unexpected conflicts. Update your application.yml to:
spring: datasource: url: jdbc:postgresql://localhost:5432/exampledb username: postgres password: postgres driver-class-name: org.postgresql.Driver liquibase: change-log: classpath:db/changelog.xml default-schema: public enabled: true
Also, make sure you've added the PostgreSQL driver to your Gradle dependencies (Spring Boot will manage its version automatically):
compile('org.postgresql:postgresql')
4. Confirm Database User Permissions
The postgres user needs sufficient permissions on the exampledb database:
- It must be able to create tables (Liquibase needs to set up
databasechangeloganddatabasechangeloglocktables). - It requires DDL permissions to apply your change sets.
5. Share the Full Exception Trace
If none of the above fixes resolve your issue, please share the complete exception stack trace. Common issues we might encounter include:
FileNotFoundException: The changelog file can't be located (path mismatch).SQLException: Failed to connect to the database (wrong credentials, Postgres not running, etc.).LiquibaseParseException: Invalid XML syntax in your changelog.
内容的提问来源于stack exchange,提问作者doublemc

