title: Spring bean creation conditionally @ConditionalOn
body: <p>I would like to create a Bean only when httpPort value not equals -1. I tried below code but It is complaining something wrong with the expression. Could you please fix this? or how to achieve my requirements.</p>
  
  <p>I am using Java 8 and Spring Boot 1.5.4</p>
  
  <p>I tried below options</p>
  
  <pre><code>@ConditionalOnExpression("'${httpPort}' ne '-1'")
  @ConditionalOnExpression("'${httpPort}' != '-1'")
  @ConditionalOnExpression("!'${httpPort}'=='-1'")
  @ConditionalOnExpression("!'${httpPort == -1}'")
  @ConditionalOnExpression("!${httpPort == -1}")
  </code></pre>
  
  <blockquote>
    <p>Most of the cases error is EL1041E: After parsing a valid expression,
    there is still more data in the expression: 'lcurly({)'</p>
  </blockquote>
  
  <pre><code>@Configuration
  public class TomcatConfig {
      @Value("${server.http.port:-1}")
      private int httpPort;
  
      @Bean
      @ConditionalOnExpression("'${httpPort}' ne '-1'")
      public EmbeddedServletContainerCustomizer containerCustomizer() {
          return new EmbeddedServletContainerCustomizer() {
              @Override
              public void customize(ConfigurableEmbeddedServletContainer container) {
                  if (container instanceof TomcatEmbeddedServletContainerFactory) {
                      TomcatEmbeddedServletContainerFactory containerFactory =
                              (TomcatEmbeddedServletContainerFactory) container;
  
                      Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
                      connector.setPort(httpPort);
                      containerFactory.addAdditionalTomcatConnectors(connector);
                  }
              }
          };
      }
  }
  </code></pre>