-Dspring.profiles.active在条件下无法识别

时间:2018-11-23 08:31:04

标签: java spring spring-boot spring-el system-properties

我已经通过<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=301880 --> <configuration> <appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Enabled" value="false" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <compilation debug="true" targetFramework="4.5.2" /> <httpRuntime targetFramework="4.5.2" maxRequestLength="1048576000"/> </system.web> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 作为系统属性:

-Dspring.profiles.active

如果我在<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>#{'dev' or 'sit' or 'qa'.equals('${spring.profiles.active}') ? 'classpath:process${spring.profiles.active}.properties' : 'classpath:env/cfg/process-${spring.profiles.active}.properties'} </value> </list> </property> </bean> 中通过了 dev ,则该条件应该通过,但是实际失败。

但是它已成功使用名为{em> process-dev.properties 的spring.profiles.active更新。

有人可以指出我所缺少的吗?

1 个答案:

答案 0 :(得分:2)

您应将其更改为| mainCol | col1 | col2 | col4 | col3 | | --------- | ---- | ---- | ---- | ---- | | 1.2.1 | 1 | 2 | | 1 | | 0.2 | 0 | 2 | | | | 1 | 1 | | | | | 1.2.1-xyz | 1 | 2 | xyz | 1 | | 1.2 | 1 | 2 | | |