2016-09-23 157 views
0

當我必須設置爲在XML屬性文件配置彈簧的應用,因爲禁用JndiProperty源使用Spring @Value註釋

<context:property-placeholder location="classpath:app.properties"/> 

我有一個查找從這裏使用@Value註釋值類。 但是,每次運行我的junit測試時,如果沒有Java應用程序服務器(Websphere),查找該值需要一段時間,如每個字段1秒。打開DEBUG模式的 顯示它是造成它的JNDI查找。

2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.core.env.PropertySourcesPropertyResolver DEBUG - Searching for key 'spring.liveBeansView.mbeanDomain' in [servletConfigInitParams] 
2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.core.env.PropertySourcesPropertyResolver DEBUG - Searching for key 'spring.liveBeansView.mbeanDomain' in [servletContextInitParams] 
2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.core.env.PropertySourcesPropertyResolver DEBUG - Searching for key 'spring.liveBeansView.mbeanDomain' in [jndiProperties] 
2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiTemplate DEBUG - Looking up JNDI object with name [java:comp/env/spring.liveBeansView.mbeanDomain] 
Sep 23, 2016 5:50:29 PM null null 
**SEVERE: javaAccessorNotSet** 
2016-09-23 17:50:29,463{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiLocatorDelegate DEBUG - Converted JNDI name [java:comp/env/spring.liveBeansView.mbeanDomain] not found - trying original name [spring.liveBeansView.mbeanDomain]. javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment. 
2016-09-23 17:50:29,463{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiTemplate DEBUG - Looking up JNDI object with name [spring.liveBeansView.mbeanDomain] 
2016-09-23 17:50:30,474{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiPropertySource DEBUG - JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message: Could not obtain an initial context due to a communication failure. Since no provider URL was specified, the default provider URL of "corbaloc:iiop:[email protected]:2809/NameService" was used. Make sure that any bootstrap address information in the URL is correct and that the target name server is running. Possible causes other than an incorrect bootstrap address or unavailable name server include the network environment and workstation network configuration.. Returning null. 

沒有問題從屬性文件中獲取值。

我需要幫助找到來配置應用程序跳過JNDI查找

回答