This commit is contained in:
sxyx2008
2014-07-04 11:09:30 +08:00
parent d160633b68
commit 50aca24919
20 changed files with 301 additions and 0 deletions
@@ -0,0 +1,11 @@
# flyway-java-example
```
mvn package exec:java
```
参考链接
[http://flywaydb.org/getstarted/firststeps/api.html](http://flywaydb.org/getstarted/firststeps/api.html)
[http://mojo.codehaus.org/exec-maven-plugin/usage.html](http://mojo.codehaus.org/exec-maven-plugin/usage.html)
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.aimeizi</groupId>
<artifactId>flyway-example</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>flyway-java-example</artifactId>
<name>flyway-java-example</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.170</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- mvn exec:java" -->
<!-- mvn exec:java -Dexec.mainClass="org.flyway.java.example.App" -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.flyway.java.example.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,22 @@
package org.flyway.java.example;
import org.flywaydb.core.Flyway;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
// Create the Flyway instance
Flyway flyway = new Flyway();
// Point it to the database
flyway.setDataSource("jdbc:h2:file:target/flyway", "sa", null);
// Start the migration
flyway.migrate();
}
}
@@ -0,0 +1,4 @@
create table PERSON (
ID int not null,
NAME varchar(100) not null
);
@@ -0,0 +1,3 @@
insert into PERSON (ID, NAME) values (1, 'Axel');
insert into PERSON (ID, NAME) values (2, 'Mr. Foo');
insert into PERSON (ID, NAME) values (3, 'Ms. Bar');