Я пытаюсь настроить процесс, в котором мы запускаем Flyway из командной строки для запуска наших миграций (из-за некоторых ограничений, наложенных на меня моими администраторами баз данных)
У меня это работает хорошо по большей части, находя и запуская SQL и обычные JdbcMigrations, но он не распознает мои SpringJdbcMigrations, утверждая, что у него нет Spring Jdbc.
Ниже найдите мою файловую структуру, свойства и вывод отладки из flyway:
Структура файла
свойства пролетного пути
#
# License removed for brevity
# Jdbc url to use to connect to the database
flyway.url=jdbc:mysql://localhost:3306/my_project
# User to use to connect to the database (default: <<null>>)
flyway.user=root
# Password to use to connect to the database (default: <<null>>)
flyway.password=XXXXXXX
# Comma-separated list of locations to scan recursively for migrations. (default: filesystem:<<INSTALL-DIR>>/sql)
# The location type is determined by its prefix.
# Unprefixed locations or locations starting with classpath: point to a package on the classpath and may contain both sql and java-based migrations.
# Locations starting with filesystem: point to a directory on the filesystem and may only contain sql migrations.
flyway.locations=classpath:com.mycompany.myproject.db.migration,filesystem:sql
# NOTE: All other properties are left as default
Отладочный вывод:
[localhost ~/Documents/ws-src/flyway-3.0] ./flyway migrate -X
/usr/bin/tput
Flyway (Command-line Tool) v.3.0
DEBUG: Adding location to classpath: /Users/biggusjimmus/Documents/ws-src/flyway-3.0/bin/../jars/java-migration.jar
DEBUG: Adding location to classpath: /Users/biggusjimmus/Documents/ws-src/flyway-3.0/bin/../jars/mysql-connector-java-5.1.26-bin.jar
#
# NOTE: This library SHOULD enable Spring Jdbc, as far as I know.
#
DEBUG: Adding location to classpath: /Users/biggusjimmus/Documents/ws-src/flyway-3.0/bin/../jars/spring-jdbc-4.0.0.RELEASE.jar
Database: jdbc:mysql://localhost:3306/myproject (MySQL 5.6)
DEBUG: DDL Transactions Supported: false
DEBUG: Schema: myproject
#
#NOTE: spring-jdbc-4.0.0.RELEASE.jar was apparently added to the classpath above!
#
DEBUG: Spring Jdbc available: false
DEBUG: Spring Jdbc available: false
DEBUG: Validating migrations ...
DEBUG: Scanning for classpath resources at 'com/mycompany/myproject/db/migration' (Prefix: 'V', Suffix: '.sql')
DEBUG: Scanning URL: jar:file:/Users/biggusjimmus/Documents/ws-src/flyway-3.0/bin/../jars/java-migration.jar!/com/mycompany/myproject/db/migration
DEBUG: JBoss VFS v2 available: false
DEBUG: Filtering out resource: com/mycompany/myproject/db/migration/ (filename: )
DEBUG: Filtering out resource: com/mycompany/myproject/db/migration/V1_1_4_2__Java_Spring_Example.class (filename: V1_1_4_2__Java_Spring_Example.class)
DEBUG: Filtering out resource: com/mycompany/myproject/db/migration/V1_1_4[localhost ~/Documents/ws-src/flyway-3.0] sh -x flyway migrate
++ pwd
+ OLDDIR=/Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ PRG=flyway
+ '[' -h flyway ']'
++ dirname flyway
+ INSTALLDIR=.
+ cd .
+ '[' -z '' ']'
+ JAVA_CMD=java
+ command -v tput
/usr/bin/tput
++ tput cols
+ CONSOLE_WIDTH=116
+ java -cp ./bin/flyway-commandline-3.0.jar:./bin/flyway-core-3.0.jar:./jars/spring-jdbc-4.0.0.RELEASE.jar org.flywaydb.commandline.Main migrate -consoleWidth=116
Flyway (Command-line Tool) v.3.0
Database: jdbc:mysql://localhost:3306/myproject (MySQL 5.6)
Validated 3 migrations (execution time 00:00.052s)
Current version of schema `myproject`: 1.1.4.3
Schema `myproject` is up to date. No migration necessary.
+ JAVA_EXIT_CODE=0
+ cd /Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ exit 0
_Java_NoSpring_Example.class (filename: V1_1_4[localhost ~/Documents/ws-src/flyway-3.0] sh -x flyway migrate
++ pwd
+ OLDDIR=/Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ PRG=flyway
+ '[' -h flyway ']'
++ dirname flyway
+ INSTALLDIR=.
+ cd .
+ '[' -z '' ']'
+ JAVA_CMD=java
+ command -v tput
/usr/bin/tput
++ tput cols
+ CONSOLE_WIDTH=116
+ java -cp ./bin/flyway-commandline-3.0.jar:./bin/flyway-core-3.0.jar:./jars/spring-jdbc-4.0.0.RELEASE.jar org.flywaydb.commandline.Main migrate -consoleWidth=116
Flyway (Command-line Tool) v.3.0
Database: jdbc:mysql://localhost:3306/myproject (MySQL 5.6)
Validated 3 migrations (execution time 00:00.052s)
Current version of schema `myproject`: 1.1.4.3
Schema `myproject` is up to date. No migration necessary.
+ JAVA_EXIT_CODE=0
+ cd /Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ exit 0
_Java_NoSpring_Example.class)
DEBUG: Scanning for classes at 'com/mycompany/myproject/db/migration' (Implementing: 'org.flywaydb.core.api.migration.jdbc.JdbcMigration')
DEBUG: Scanning URL: jar:file:/Users/biggusjimmus/Documents/ws-src/flyway-3.0/bin/../jars/java-migration.jar!/com/mycompany/myproject/db/migration
DEBUG: JBoss VFS v2 available: false
DEBUG: Filtering out resource: com/mycompany/myproject/db/migration/ (filename: )
#
# NOTE: Why did it find the NoSpring example (which implements JdbcMigration),
# but not the spring example (which implements SpringJdbcMigration), even though
# it's in the same package?
# Presumably because it doesn't think it has Spring Jdbc support
#
DEBUG: Found class: com.mycompany.myproject.db.migration.V1_1_4[localhost ~/Documents/ws-src/flyway-3.0] sh -x flyway migrate
++ pwd
+ OLDDIR=/Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ PRG=flyway
+ '[' -h flyway ']'
++ dirname flyway
+ INSTALLDIR=.
+ cd .
+ '[' -z '' ']'
+ JAVA_CMD=java
+ command -v tput
/usr/bin/tput
++ tput cols
+ CONSOLE_WIDTH=116
+ java -cp ./bin/flyway-commandline-3.0.jar:./bin/flyway-core-3.0.jar:./jars/spring-jdbc-4.0.0.RELEASE.jar org.flywaydb.commandline.Main migrate -consoleWidth=116
Flyway (Command-line Tool) v.3.0
Database: jdbc:mysql://localhost:3306/myproject (MySQL 5.6)
Validated 3 migrations (execution time 00:00.052s)
Current version of schema `myproject`: 1.1.4.3
Schema `myproject` is up to date. No migration necessary.
+ JAVA_EXIT_CODE=0
+ cd /Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ exit 0
_Java_NoSpring_Example
DEBUG: Scanning for filesystem resources at 'sql' (Prefix: 'V', Suffix: '.sql')
DEBUG: Scanning for resources in path: sql (sql)
DEBUG: Filtering out resource: sql/.DS_Store (filename: .DS_Store)
DEBUG: Found filesystem resource: sql/V1_1[localhost ~/Documents/ws-src/flyway-3.0] sh -x flyway migrate
++ pwd
+ OLDDIR=/Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ PRG=flyway
+ '[' -h flyway ']'
++ dirname flyway
+ INSTALLDIR=.
+ cd .
+ '[' -z '' ']'
+ JAVA_CMD=java
+ command -v tput
/usr/bin/tput
++ tput cols
+ CONSOLE_WIDTH=116
+ java -cp ./bin/flyway-commandline-3.0.jar:./bin/flyway-core-3.0.jar:./jars/spring-jdbc-4.0.0.RELEASE.jar org.flywaydb.commandline.Main migrate -consoleWidth=116
Flyway (Command-line Tool) v.3.0
Database: jdbc:mysql://localhost:3306/myproject (MySQL 5.6)
Validated 3 migrations (execution time 00:00.052s)
Current version of schema `myproject`: 1.1.4.3
Schema `myproject` is up to date. No migration necessary.
+ JAVA_EXIT_CODE=0
+ cd /Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ exit 0
_Base_version.sql
DEBUG: Found filesystem resource: sql/V1_1_4_1__SQL_Example.sql
Validated 3 migrations (execution time 00:00.052s)
DEBUG: Schema `myproject` already exists. Skipping schema creation.
DEBUG: Locking table `myproject`.`schema_version`...
DEBUG: Lock acquired for table `myproject`.`schema_version`
Current version of schema `myproject`: 1.1.3
Migrating schema `myproject` to version 1.1.4.1
DEBUG: Successfully completed and committed migration of schema `myproject` to version 1.1.4.1
DEBUG: MetaData table `myproject`.`schema_version` successfully updated to reflect changes
DEBUG: Locking table `myproject`.`schema_version`...
DEBUG: Lock acquired for table `myproject`.`schema_version`
Migrating schema `myproject` to version 1.1.4.3
DEBUG: Successfully completed and committed migration of schema `myproject` to version 1.1.4.3
DEBUG: MetaData table `myproject`.`schema_version` successfully updated to reflect changes
DEBUG: Locking table `myproject`.`schema_version`...
DEBUG: Lock acquired for table `myproject`.`schema_version`
Successfully applied 2 migrations to schema `myproject` (execution time 00:00.049s).
Если есть какая-либо другая информация, которую я могу предоставить, которая может быть полезной, пожалуйста, дайте мне знать.
РЕДАКТИРОВАТЬ: я также попытался изменить сценарий оболочки оболочки, чтобы напрямую добавить jar spring-jdbc в его путь к классам. Запуск с этой модификацией не вызвал видимых изменений.
Запуск с этим изменением (поверх обновленной базы данных и без флага отладки) дал следующий результат:
[localhost ~/Documents/ws-src/flyway-3.0] sh -x flyway migrate
++ pwd
+ OLDDIR=/Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ PRG=flyway
+ '[' -h flyway ']'
++ dirname flyway
+ INSTALLDIR=.
+ cd .
+ '[' -z '' ']'
+ JAVA_CMD=java
+ command -v tput
/usr/bin/tput
++ tput cols
+ CONSOLE_WIDTH=116
+ java -cp ./bin/flyway-commandline-3.0.jar:./bin/flyway-core-3.0.jar:./jars/spring-jdbc-4.0.0.RELEASE.jar org.flywaydb.commandline.Main migrate -consoleWidth=116
Flyway (Command-line Tool) v.3.0
Database: jdbc:mysql://localhost:3306/myproject (MySQL 5.6)
Validated 3 migrations (execution time 00:00.052s)
Current version of schema `myproject`: 1.1.4.3
Schema `myproject` is up to date. No migration necessary.
+ JAVA_EXIT_CODE=0
+ cd /Users/biggusjimmus/Documents/ws-src/flyway-3.0
+ exit 0