Clausと同様にuseOverridePropertiesWithConfigAdmin
メソッドを使用する必要があります。ただし、青写真に設定されているのと同じpid値を返す必要があります。
あなたの青写真:あなたのテストの追加
<cm:property-placeholder id="props.placeholder" persistent-id="props.blueprint">
<cm:default-properties>
...
<cm:property name="time.daysHistory" value="4" />
</cm:default-properties>
</cm:property-placeholder>
:
@Override
protected String useOverridePropertiesWithConfigAdmin(Dictionary props) {
props.put("time.daysHistory", "1");
return "props.blueprint";
}
EDIT:私のルートで
私が注入されたプロパティ:ここに が、私はそれを行っている方法です
@PropertyInject("DatasetConsumePath")
private String datasetConsumePath;
@PropertyInject("DatasetFileExtension")
private String datasetFileExtension;
私の青写真:
<cm:property-placeholder id="test" persistent-id="test" update-strategy="reload">
<cm:default-properties>
<cm:property name="DatasetConsumePath" value="test"/>
<cm:property name="DatasetFileExtension" value="txt"/>
<cm:property name="DatasetAggregateBatchSize" value="1000"/>
</cm:default-properties>
</cm:property-placeholder>
私のテスト:
@Override
protected String useOverridePropertiesWithConfigAdmin(Dictionary props) {
// add the properties we want to override
props.put("DatasetConsumePath", "src/test/resources/test files/test/");
// return the PID of the config-admin we are using in the blueprint xml file
return "test";
}
これが機能していません。 '' useOverridePropertiesWithConfigAdmin''で与えられたディクショナリのサイズは0です。そして、blueprint.xmlで与えられた値は引き続き使用されます。 - 私は、私のテストの中からblueprint.xmlで与えられた値を上書きしたい/読みたい。 – dermoritz