Spring 框架 JNDI 中的异常处理

Exception Handling in Spring Framework JNDI

 I have configured JNDI reference in spring-context.xml ,created JNDI in Websphere application server 7.5, this working fine, but if its database is down, I am not able to start the web application ,i am getting 500 uncaught servlet initialization exception .

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="${reports_db_jndi_ref}"/>
</bean>

能请教一下吗?如何处理异常或如何在数据库已关闭的情况下启动 Web 应用程序?

将 lookupOnStartup 属性 设置为 false,以便 Spring returns 数据源的代理而不是实际的数据源。但是,如果您的应用程序将数据源用作启动过程的一部分,例如由于某些依赖项试图连接到数据库,仍然会发生循环。变化如下

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="${reports_db_jndi_ref}"/>
    <property name="lookupOnStartup" value="false"/>
</bean>