schemacrawler 从所有可用数据库返回表

schemacrawler returning tables from all available databases

我正在使用 schemacrawler 从 mysql 数据库中获取 table 列表。问题是,结果包括来自所有可用数据库的 table。它正在从给定数据库名称 (DataSource) 外部获取 tables。

<bean id="schemaCrawlerOptions" class="schemacrawler.schemacrawler.SchemaCrawlerOptions">
    <property name="sequenceInclusionRule">
        <bean class="schemacrawler.schemacrawler.IncludeAll" />
    </property>
    <property name="tableTypes">
        <set>
            <value>TABLE</value>
            <!-- <value>VIEW</value> -->
        </set>
    </property>
    <property name="schemaInfoLevel">
        <bean factory-method="standard"
            class="schemacrawler.schemacrawler.SchemaInfoLevel" />
    </property>
</bean>
<bean id="executableForSchema" class="schemacrawler.tools.text.schema.SchemaTextExecutable"> <!-- This is the final class we need to execute schemacrawler -->
    <constructor-arg value="schema" />
    <property name="schemaCrawlerOptions" ref="schemaCrawlerOptions" />
    <property name="schemaTextOptions">
        <bean class="schemacrawler.tools.text.schema.SchemaTextOptions">
            <property name="showOrdinalNumbers" value="false" />
            <property name="showStandardColumnTypeNames" value="false" />
            <property name="hidePrimaryKeyNames" value="true" />
            <property name="hideIndexNames" value="true" />
            <property name="hideForeignKeyNames" value="true" />
            <property name="hideConstraintNames" value="true" />
            <property name="noInfo" value="false" />
        </bean>
    </property>
    <property name="outputOptions" ref="outputOptions" />
</bean>

这是我的 spring-上下文。

Khader,此行为实际上取决于数据库的权限,而不取决于您使用的数据源。如果您的数据库用户有权访问 table,SchemaCrawler 将报告它,而不管它属于什么模式。因此,最好使用具有有限访问权限的数据库用户,而不是系统管理员帐户。

但是,您可以让 SchemaCrawler 限制它报告的模式和 tables。您需要在 schemaCrawlerOptions 上设置 schemaInclusionRule 和可选的 tableInclusionRule。

换句话说,请适当设置:

<bean id="schemaCrawlerOptions" class="schemacrawler.schemacrawler.SchemaCrawlerOptions"> <property name="schemaInclusionRule"> ... ... <!-- Set an appropriate value here --> </property> ... ... ... </bean>

苏阿莱。