繁体   English   中英

dropwizard多个表

[英]dropwizard multiple tables

如何在dropwizard的单个数据库中创建两个表?

在我的运行方法中,我有:

public void run(HelloWorldConfiguration configuration, Environment environment) {
    final PersonDAO dao = new PersonDAO(hibernateBundle.getSessionFactory());
    final LADAO dao2 = new LADAO(hibernateBundle.getSessionFactory());
    environment.jersey().register(new ProtectedResource());
    environment.jersey().register(new PeopleResource(dao));
    environment.jersey().register(new PersonResource(dao));
    environment.jersey().register(new LAResource(dao2));}

在您的migrations.xml文件中创建表

<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.0.xsd">

    <changeSet id="1" author="people">
        <!-- first table created -->
        <createTable tableName="table1">
            <column name="jobTitle" type="varchar(255)"/>
        </createTable>
        <!-- second table created -->
        <createTable tableName="table2">
            <column name="whatever" type="varchar(255)"/>
        </createTable>
    </changeSet>
</databaseChangeLog>

然后使用“ db migration”命令运行迁移:

java -jar hello-world.jar db migrate helloworld.yml

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM