私はもともと、レイアウトの次の並べ替えを使用してXMLファイルを持っていた理由はわからない:ビーンズ -
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="FirstBean">...</bean>
<bean id="SecondBean">...</bean>
<bean id="ThirdBean">...</bean>
</beans>
私たちのためにうまくいきました。しかし、今日では、特定の環境(生産とテスト)でBeanの一部をインスタンス化したいだけで、プロファイルを作成する必要があることがわかりました。 - アプリケーションの初期起動時に - 私が行う以下の
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Beans to run commonly amongst both profiles -->
<beans>
<bean id="FirstBean">...</bean>
</beans>
<!-- Beans to run in prod -->
<beans profile="production">
<bean id="SecondBean">...</bean>
</beans>
<!-- Beans to run in test -->
<beans profile="test">
<bean id="ThirdBean">...</bean>
</beans>
</beans>
その後...正しい豆をロードするために豆を得るために次のように我々は、いくつかの要素を入れ子にし、プロファイルを追加することによって、これをしませんでした(現在はテスト目的のためにハードコード):
System.setProperty("spring.profiles.active", "test");
私も試してみました:
System.setProperty("spring.profiles.active", "production");
をしかし、今、私はすべての3つの豆の「そのようなBean定義」を取得していない続けます。
ここに十分な情報を提供していただきたいと思います。私は本当にこれに固執しています - 様々なオンラインリソースに従っています。
少なすぎる情報を、スニペットと概要は表示されません。時には、いくつかのBeanの起動時にそれらのプロパティを設定しようとしている場合、それらのプロパティをいつ/どこで設定していますか。 –