Maven <filter>
タグとSpringの設定で動作するこの奇妙な動作があります。私の理解は、Springの設定はMavenのプレーンなXMLファイルだが、私は<context:component-scan base-package="com.xyz"/>
タグに関する問題に遭遇している。テストXMLファイルはSpringの設定とMavenプロファイルの奇妙な振る舞い
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"
default-autowire="byName">
<!-- Import the DataSource configurations -->
<import resource="classpath:spring/MyDataSource.xml"/>
<!-- Property File location -->
<context:property-placeholder location="${ext.properties.dir}"/>
<!--The services are auto-detected POJOs labeled with the @Service annotation.-->
<context:component-scan base-package="com.xyz"/>
</beans>
以下のようで、Mavenは
ext.properties.dir=file:///C:/Temp/myProp.properties
私の問題があること
だっいるbuild-dev.propertiesの<build>
.....
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/resources/build/build-${environment}.properties</filter>
</filters>
</build>
<profiles>
<profile>
<id>uat</id>
<activation>
<property>
<name>env</name>
<value>uat</value>
</property>
</activation>
<properties>
<environment>uat</environment>
</properties>
</profile>
<profile>
<id>prod</id>
<activation>
<property>
<name>env</name>
<value>prod</value>
</property>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<environment>prod</environment>
</properties>
</profile>
</profiles>
内容以下のような構成プロファイルMavenプロファイルのフィルタリングが機能していないため、パッケージ化プロセス中にプロパティ${ext.properties.dir}
が置き換えられませんでした。それは、私が<context:component-scan base-package="com.xyz"/>
タグを取り除いたときに働いていたので、フィルタリングする必要があるプロパティの下に配置しました。今はすべて正常に動作します。私の質問は<context:component-scan base-package="com.xyz"/>
の問題点ですか?
あなたはターゲットを右に打ちました。 Mavenフィルタで '@'が使用されていることを教えていただけたらいいですね。メイヴンは、それを見て何を理解していますか? –
PropertyPlaceholderの場所は、環境に基づいたプロパティファイルから来るので、私はそれを避けることはできません.Linuxは、Windowsの場所とは異なるプロパティファイルの別のパスを持っています。どうもありがとう。 –
@Aravind A:アイデアはそのプロパティファイルの背後にあり、常に同じファイル(別の要素)を持ち、クラスパス内の同じ場所にあるため、勝つかどうかは関係ありません。 – Ralph