maven使用liqubase管理数据库

来源:互联网 发布:扣扣群发软件 编辑:程序博客网 时间:2024/06/03 14:55

第二次使用maven的liqubase插件在项目启动的时候自动建表,记录一下,备忘:


使用eclipse的maven插件:


changelog.xml

<?xml version="1.0" encoding="UTF-8"?><databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"><changeSet id="xxx-2015-6-30-1" author="jiangyu"> <sqlFile path="city_table_struct.sql" encoding="UTF-8"relativeToChangelogFile="true" /></changeSet><changeSet id="xxx-2015-6-30-2" author="jiangyu"> <sqlFile path="city_init_data.sql" encoding="UTF-8"relativeToChangelogFile="true" /></changeSet></databaseChangeLog>

pom文件配置:

<plugin><groupId>org.liquibase</groupId><artifactId>liquibase-maven-plugin</artifactId><version>3.0.5</version><configuration><changeLogFile>src/main/resources/city/cityinit.changelog.xml</changeLogFile><driver>${dataSource.project.driverClass}</driver><url>${dataSource.project.jdbcURL}</url><username>${dataSource.project.user}</username><password>${dataSource.project.password}</password></configuration><executions><execution><phase>process-resources</phase><goals><goal>update</goal></goals></execution></executions></plugin>
<pre name="code" class="html"><pluginManagement><plugins><!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --><plugin><groupId>org.eclipse.m2e</groupId><artifactId>lifecycle-mapping</artifactId><version>1.0.0</version><configuration><lifecycleMappingMetadata><pluginExecutions><pluginExecution><pluginExecutionFilter><groupId>org.liquibase</groupId><artifactId>liquibase-maven-plugin</artifactId><versionRange>[3.0.5,)</versionRange><goals><goal>update</goal></goals></pluginExecutionFilter><action><ignore></ignore></action></pluginExecution></pluginExecutions></lifecycleMappingMetadata></configuration></plugin></plugins></pluginManagement>




0 0
原创粉丝点击