我已经在spring中配置了JNDI引用
<bean id="optionalBean" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="name"/>
</bean>
但是无法配置此 JNDI 属性。在这种情况下,我的 Tomcat 无法启动。
我如何告诉Spring这个JNDI是可选的?
更新:
添加 lookupOnStartup
后出现错误:
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'optionalBean': Cannot resolve reference to bean 'optionalBean' while setting bean property 'optionalBean';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'optionalBean':
Invocation of init method failed; nested exception is java.lang.IllegalStateException:
Cannot deactivate 'lookupOnStartup' without specifying a 'proxyInterface' or 'expectedType'
最佳答案
这应该可以
<bean id="optionalBean" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName" value="name"/>
</bean>
关于java - 处理 JNDI 缺失的情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39371852/