1

When deploying "regular" web apps to Liberty, I was used to binding the global datasource configured in Liberty's server.xml to the individual application by using a child element within the element, like this:

   <application context-root="helloApp" location="..." name="helloApp" type="war">
        <application-bnd>
             <data-source id="db2appDs" name="jdbc/datasource" binding-name="jdbc/theDB"/>
        </application-bnd>
        ...
    </application>
    <dataSource id="db2ds" jndiName="jdbc/theDB" type="javax.sql.DataSource">        
        ...
    </dataSource>   

When configuring my first Spring Boot application to deploy to Liberty, I am trying to use the new <springBootApplication> element for it - but I don't seem to be able to add a binding for the datasource I want to use the same way, as this element doesn't seem to support such a child. (It seems to want only <classloader> as a child). I've seen people suggest I use an @Resource annotation that includes both application-local JDNI name and global JNDI name for the datasorce - but that defeats the purpose, since I don't want to know what the global name is until deploy time.

Is there another way to do this, like we used to before? Or are applications deployed through <springBootApplication> expected to know the global JNDI name of the datasource(s) they want?

moilejter
  • 958
  • 8
  • 9

1 Answers1

0

Application-defined datasources are not supported for <springBootApplication/>’s. While your application may certainly access a Liberty datasource using its global JNDI name, you should configure the spring.datasource.jndi-name property within your Spring Boot application as described in section 29.1.3 of the Spring Boot features reference. For your example try spring.datasource.jndi-name=jdbc/theDB.

Dave Zavala
  • 171
  • 3