使用 Spring @Value 注释时禁用 JndiProperty 源

disable JndiProperty source when using Spring @Value annotation

我有一个 spring 应用配置为在 xml 上有一个 属性 文件配置作为

 <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:1.0@mymachine: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 查找的最佳方法

我创建了一个 spring.properties 文件并添加了这个值 spring.jndi.ignore=true