1

mysql データベースからテーブル リストを取得するために schemacrawler を使用しています。問題は、結果に利用可能なすべてのデータベースのテーブルが含まれることです。指定されたデータベース名(DataSource)の外部からテーブルを取得しています。

<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>

これが私の春のコンテキストです。

4

1 に答える 1

0

Khader さん、この動作は実際には、使用しているデータ ソースではなく、データベースの権限に依存します。データベース ユーザーがテーブルへのアクセス権を持っている場合、SchemaCrawler はそれが属しているスキーマに関係なく、それを報告します。そのため、sysadmin アカウントではなく、アクセスが制限されたデータベース ユーザーを使用することをお勧めします。

ただし、SchemaCrawler がレポートするスキーマとテーブルを制限することができます。schemaCrawlerOptions で schemaInclusionRule を設定し、オプションで tableInclusionRule を設定する必要があります。

つまり、これを適切に設定してください。

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

スアレ。

于 2015-03-18T21:28:22.367 に答える