简体   繁体   English

在春季加载Tomcat资源

[英]Loading Tomcat Resource in Spring

Within my server.xml I have something like the following line: 在我的server.xml中,我有类似以下行的内容:

  <GlobalNamingResources>
<!-- Editable user database that can also be used by
     UserDatabaseRealm to authenticate users
-->
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
<Resource factory="com.company.ServerEnvironmentFactory" name="config/ServerEnvironment" type="java.util.Map"/>

Within Spring 3, how to do ensure that the ServerEnvironmentFactory is created, such that I can do a Context lookup for java:/comp/env/config/ServerEnvironment. 在Spring 3中,如何确保创建了ServerEnvironmentFactory,这样我就可以对java:/ comp / env / config / ServerEnvironment进行上下文查找。

Thank you 谢谢

我认为您需要配置context.xml,以便所有应用程序都知道全局资源。

<ResourceLink global="config/ServerEnvironment" name="config/ServerEnvironment" type="java.util.Map" />

Give this a try: 试试看:

<bean id="myEnv" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:/comp/env/config/ServerEnvironment"/>
</bean>

Resources: 资源:

Tomcat Java JNDI Example Tomcat Java JNDI示例

Spring JNDI Example Spring JNDI示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM