为了账号安全,请及时绑定邮箱和手机立即绑定

初始化上下文:属性占位符取决于 Maven 配置文件

初始化上下文:属性占位符取决于 Maven 配置文件

元芳怎么了 2021-09-12 16:01:24
我有一个名为 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>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 123 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信