【问题标题】:Loading properties file from Weblogic Server inside Spring Bean Configuration file在 Spring Bean 配置文件中从 Weblogic Server 加载属性文件
【发布时间】:2018-01-05 06:20:32
【问题描述】:

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

在以下路径中创建了一个项目特定文件夹 appConfig: Oracle/Middleware/ORACLE_HOME/user_projects/domains/wl_server/config/appConfig

将名为 commonConfig.properties 的属性文件放入其中。

还使用以下条目编辑了 setDomainEnv.cmd

  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 请在下面找到异常堆栈跟踪

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)

谁有合适的解决方案?

【问题讨论】:

    标签: java spring spring-mvc weblogic12c


    【解决方案1】:
    <bean id="commonProps"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations" value="classpath*:config/appConfig/commonConfig"/>
    </bean>
    

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

    【讨论】:

      猜你喜欢
      • 2012-05-27
      • 2011-02-27
      • 2020-06-05
      • 2016-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-30
      • 2015-11-22
      相关资源
      最近更新 更多