You can fake removing spring.datasource.jndi-name from application.property by setting spring.datasource.jndi-name=false
. This way @ConditionalOnProperty(prefix = "spring.datasource", name = "jndi-name")
won’t enable autoconfiguration class. For details look at ConditionalOnProperty javadoc.