我有一個名為 provider.xml 的 spring 文件<context:property-placeholder location="classpath:META-INF/spring/${build.profile.id}/config.properties" />我有兩個不同的 config.properties 一個在 META-INF/spring/ws1 中,另一個在 META-INF/spring/ws2這是我的 pom.xml 的一部分<profiles> <profile> <id>ws1</id> <properties> <build.profile.id>ws1</build.profile.id> </properties> </profile> <profile> <id>ws2</id> <properties> <build.profile.id>ws2</build.profile.id> </properties> </profile></profiles>我收到此錯誤:Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [META-INF/spring/${build.profile.id}/config.properties] cannot be opened because it does not exist但是,如果我嘗試在沒有像這樣的變量的情況下閱讀它,它是有效的: <context:property-placeholder location="classpath:META-INF/spring/ws1/config.properties" /> 如何在 context:property-placeholder 中將其作為變量讀取?在我將此代碼添加到 provider.xml 之后<bean id="propertyPlaceholderConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /><property name="searchSystemEnvironment" value="true" /></bean>
添加回答
舉報
0/150
提交
取消