我的項目需要初始上下文工廠和提供程序URL從屬性文件加載。這裏是我的Spring配置Spring,JndiTemplate外部化提供程序URL
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate" lazy-init="true">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">${initial.context.factory}</prop>
<prop key="java.naming.provider.url">${provider.url}</prop>
</props>
</property>
</bean>
<bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true" depends-on="jndiTemplate">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>${queue.connection.factory}</value>
</property>
</bean>
這裏是如何我Spring容器初始化
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
ppc.setProperties(ConfigManager.getProperties());
AbstractApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
context.addBeanFactoryPostProcessor(ppc);
context.refresh();
的初始化的QueueConnectionFactory拋出一個異常,
異常線程 「main」 org.springframework.beans .factory.BeanCreationException:在類路徑資源[spring-config.xml]中定義名稱爲'jmsQueueConnectio nFactory'的bean時創建錯誤:調用in它的方法失敗了;嵌套異常是javax.naming.Com municationException [根異常是java.net.ConnectException:http://maven.apache.org/ingestionservices-core:沒有已知的有效por t用於:'Default [http]:http(http):null:-1:192.168.50.160: -1' ;沒有可用的路由器到目的地] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFa ctory.java:1412) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFact ORY。 Java的:519) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactor y.java:456) 在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:291 ) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222 ) 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) 在org.springframework。 beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support。 AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java: 1075) at com .quickplay.ingestionservices.poolmgr.PoolManager.initialize(PoolManager.java:143) at com.quickplay.ingestionservices.poolmgr.PoolManager。(PoolManager.java:56) at com.quickplay.ingestionservices.poolmgr.PoolManager.main( PoolManager.java:47)
看起來好像provider.url屬性沒有正確配置。它工作,如果我硬編碼提供商的網址。有人能指出發生了什麼嗎?由於