我的春季3.2.4的webapp运行正常.但是当我启动它时,我将获得调试信息:
2014-05-20 11:11:47 DEBUG JndiTemplate:150 - Looking up JNDI object with name [java:comp/env/spring.liveBeansView.mbeanDomain]
2014-05-20 11:11:47 DEBUG JndiLocatorDelegate:101 - Converted JNDI name [java:comp/env/spring.liveBeansView.mbeanDomain] not found - trying original name [spring.liveBeansView.mbeanDomain]. javax.naming.NameNotFoundException: Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to find [spring.liveBeansView.mbeanDomain].
2014-05-20 11:11:47 DEBUG JndiTemplate:150 - Looking up JNDI object with name [spring.liveBeansView.mbeanDomain]
2014-05-20 11:11:47 DEBUG JndiPropertySource:87 - JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message: Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to find [spring.liveBeansView.mbeanDomain].. Returning null.
2014-05-20 11:11:47 DEBUG PropertySourcesPropertyResolver:81 - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties]
2014-05-20 11:11:47 DEBUG PropertySourcesPropertyResolver:81 - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment]
2014-05-20 11:11:47 DEBUG PropertySourcesPropertyResolver:103 - Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null]
2014-05-20 11:11:47 DEBUG DispatcherServlet:533 - Published WebApplicationContext of servlet 'spring' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring]
Run Code Online (Sandbox Code Playgroud)
我不知道这些信息是什么意思.我c3p0用作我的dataSource,配置是:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/config/jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="autoCommitOnClose" value="true"/>
<property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>
<property name="initialPoolSize" value="${cpool.minPoolSize}"/>
<property name="minPoolSize" value="${cpool.minPoolSize}"/>
<property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
<property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
<property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="simpleJdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<constructor-arg ref="jdbcTemplate" />
</bean>
Run Code Online (Sandbox Code Playgroud)
我无法找到JNDI使用的位置.我已经搜索了一些有关此异常的问题.但他们总是与@Profile或相关联@Configuration.没有@Profile或@Configuration在我的代码中.
在我的bean类中,没有@Bean注释.这些信息与此相关吗?但是我不需要spring注入我的bean类.
rek*_*nyz 12
如果您不使用任何配置文件或mbeans,只需将以下context-params添加到web.xml作为解决方法(技巧),希望有人可以提供比这个丑陋的解决方案更好的解决方案.
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</context-param>
<context-param>
<param-name>spring.liveBeansView.mbeanDomain</param-name>
<param-value>dev</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
这是JIRA问题,并简要解释了为什么它在第3季度第一次被引入.此外,您可以在此功能的初始提交中找到更多详细信息.
基本上,这个功能是一种通过JMX公开存在于某个应用程序的应用程序上下文中的bean的实时列表的方法.例如,您在Tomcat中部署了一个Web应用程序,并在启动时将其作为一个名为的环境变量传递给它spring.liveBeansView.mbeanDomain.让我们说你不给它任何值,或只是一个空字符串.Spring会搜索这类属性的一长串可能位置,并在系统环境中找到它.如果发现它将知道通过JMX公开活动bean列表(采用JSON格式).
如果您将JConsole连接到Tomcat实例,您将看到一个名为的条目,DefaultDomain并在其下面显示您的应用程序名称.如果你扩展它应该有一个被调用的属性SnapshotAsJson,这是来自webapp的应用程序上下文的bean的实时列表.
如果你给你的系统环境变量一个值,让我们说"test_domain",在JMX中,该条目将被调用test_domain而不是DefaultDomain.
所以,基本上你会看到那些DEBUG消息,因为Spring spring.liveBeansView.mbeanDomain在很长的位置列表中搜索属性,JNDI(在JEE服务器的情况下)是其中之一.
在最新版本的SpringSource Tool Suite中(可能还有一些早期版本),有一个功能可以利用这个名为"Live Beans Graph"的活动JMX曝光,它采用JSON表示并创建一些基本的图形表示.豆子.
| 归档时间: |
|
| 查看次数: |
45660 次 |
| 最近记录: |