title: How to ignore Java EE data source using Spring logic?
body: <p>I have a Java EE datasource which I just want to be invoked if a property is set. Can a system property or vm argument be set so as to just use this Java EE datasource if its true. Spring attempts to connect to this jndi datasource on server startup but I need to control when this connection is made. So in certain situations Spring should not attempt to make a connection to datasource "myDataSource" . Here is the config within my context file : </p>
  
  <pre><code>&lt;jee:jndi-lookup id="myDataSource" jndi-name="jdbc/mydb"
          resource-ref="true" expected-type="javax.sql.DataSource" /&gt;
  </code></pre>
  
  <p>Can I use spring expressions to control this : </p>
  
  <p><a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html" rel="nofollow noreferrer">http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html</a></p>
  
  <p>Reading the accepted answer here : </p>
  
  <p><a href="https://stackoverflow.com/questions/6906863/conditional-statement-inside-spring-config">Conditional statement inside Spring config</a>
  I may be able to use a vm argument to indicate if the jndi datasource should be used ?</p>