代码之家  ›  专栏  ›  技术社区  ›  Sumit Ghosh

在SpringBean配置文件中从Weblogic服务器加载属性文件

  •  0
  • Sumit Ghosh  · 技术社区  · 9 年前

    我正在使用Spring mvc开发一个Web应用程序,使用Weblogic-12.2.1作为 应用服务器。我想将所有属性文件保存在我的应用服务器中。为此,我执行了以下步骤:

    在以下路径中创建了特定于项目的文件夹appConfig: Oracle/Middleware/Oracle\u HOME/user\u projects/domains/wl\u server/config/appConfig

    commonConfig.properties 在它里面。

    还编辑了 包含以下条目:

      if NOT "%EXT_POST_CLASSPATH%"=="" (
        set EXT_POST_CLASSPATH=%EXT_POST_CLASSPATH%;%DOMAIN_HOME%\config\appConfig
        if NOT "%POST_CLASSPATH%"=="" (
           set POST_CLASSPATH=%POST_CLASSPATH%;%EXT_POST_CLASSPATH%
        ) else (
           set POST_CLASSPATH=%EXT_POST_CLASSPATH%
      )
    )
    

    请在下面找到我的Spring bean配置文件:

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">
    
      <bean id="commonProps"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
          <property name="location" value="classpath:config/appConfig/commonConfig"/>
      </bean>
      </beans>
    

    但在部署期间 FileNotFoundException 请查找以下异常stacktrace

    Caused by: java.io.FileNotFoundException: class path resource [config/appConfig/commonConfig] cannot be opened because it does not exist
    
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
    at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:154)
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:80)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:281)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:161)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:705)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
    at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
    at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
    at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
    at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:251)
    at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:204)
    at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:189)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1911)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3091)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1823)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:882)
    at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
    at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
    at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
    

    1 回复  |  直到 9 年前
        1
  •  0
  •   Sumit Ghosh    9 年前
    <bean id="commonProps"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations" value="classpath*:config/appConfig/commonConfig"/>
    </bean>
    

    上述配置在weblogic server中成功运行。