您的位置:首页 > 数据库

使用flyway-maven-plugin,执行数据库初始化sql文件,和sql数据库升级

2014-11-18 13:36 836 查看
https://github.com/Dreampie/flyway-maven-pluginflyway-maven-plugin插件:
目前刚刚发布第一个版本1.0:
<flyway-maven-plugin.version>1.0</flyway-maven-plugin.version>


使用方式:

maven配置文件pom.xml里配置
<plugin>
<groupId>cn.dreampie</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>${flyway-maven-plugin.version}</version>
<configuration>
<config>${basedir}/src/main/resources/application.properties</config><!--数据库配置文件-->
<location>filesystem:${basedir}/src/main/resources/db/migration/</location><!--数据库sql文件目录-->
</configuration>
<dependencies>
<dependency><!--添加相应的数据库driver-->
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
</dependencies>
</plugin>


application.properties配置数据库 相关参数
devMode = true

db.default.driver=com.mysql.jdbc.Driver
db.default.url=jdbc:mysql://192.168.1.211/shm_order?useUnicode=true&characterEncoding=UTF-8
db.default.user=dev
db.default.password=dev1010

#db.default.driver=org.h2.Driver
#db.default.url=jdbc:h2:file:./db/icedog
#db.default.user=sa
#db.default.password=file password icedog
# Connection Pool settings
db.default.poolInitialSize=10
db.default.poolMaxSize=20
db.default.connectionTimeoutMillis=1000
#In production mode, migration is done automatically if db.${dbName}.migration.auto
#is set to be true in application.conf. Otherwise it failed to start when migration is needed.
db.default.valid.clean=true
db.default.migration.auto=true
db.default.migration.initOnMigrate=true


该版本支持jdk1.5+,如果不启动项目运行插件,执行命令 cn.dreampie:flyway:1.0:migrate 或者使用ide相应的快捷键,同样可以执行sql

https://github.com/Dreampie?tab=repositories 目录下有多款插件:
cn.dreampie.flyway-maven-plugin https://github.com/Dreampie/flyway-maven-plugin flyway-maven数据库升级插件
cn.dreampie.coffeescript-maven-plugin https://github.com/Dreampie/coffeescript-maven-plugin coffeescript-maven插件
cn.dreampie.lesscss-maven-plugin https://github.com/Dreampie/lesscss-maven-plugin lesscss-maven插件
cn.dreampie.jfinal-shiro https://github.com/Dreampie/jfinal-shiro shiro插件
cn.dreampie.jfinal-shiro-freemarker https://github.com/Dreampie/jfinal-shiro-freemarker shiro插件实现的freemarker标签库
cn.dreampie.jfinal-web https://github.com/Dreampie/jfinal-web 相关web插件,简洁model实现
cn.dreampie.jfinal-utils https://github.com/Dreampie/jfinal-utils 部分jfinal工具
cn.dreampie.jfinal-tablebind https://github.com/Dreampie/jfinal-tablebind jfinal的table自动绑定插件,支持多数据源
cn.dreampie.jfinal-flyway https://github.com/Dreampie/jfinal-flyway 数据库脚本升级插件,开发中升级应用时,使用脚本同步升级数据库或者回滚
cn.dreampie.jfinal-captcha https://github.com/Dreampie/jfinal-captcha 基于jfinal render的超简单验证吗插件
cn.dreampie.jfinal-quartz https://github.com/Dreampie/jfinal-quartz 基于jfinal 的quartz管理器
cn.dreampie.jfinal-sqlinxml https://github.com/Dreampie/jfinal-sqlinxml 基于jfinal 的类似ibatis的sql语句管理方案
cn.dreampie.jfinal-lesscss https://github.com/Dreampie/jfinal-lesscss java实现的lesscsss实时编译插件,可以由于jfinal
cn.dreampie.jfinal-coffeescript https://github.com/Dreampie/jfinal-coffeescript java实现的coffeescript实时编译插件,可以由于jfinal
cn.dreampie.jfinal-akka https://github.com/Dreampie/jfinal-akka java使用akka执行异步任务
cn.dreampie.jfinal-mailer https://github.com/Dreampie/jfinal-mailer 使用akka发布邮件的jfinal插件
cn.dreampie.jfinal-slf4j https://github.com/Dreampie/jfinal-slf4j 让jfinal使用slf4j的日志api

部分内容借鉴了网络资料
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐