2017-07-29 129 views
0

我正在开发一个使用Spring mvc的Web应用程序,使用Weblogic-12.2.1作为 应用程序服务器。我希望将所有属性文件保留在我的应用程序服务器中。这样做的以下步骤:从Spring Bean中的Weblogic服务器加载属性文件配置文件

创建项目特定文件夹的AppConfig在以下路径: 甲骨文/中间件/ ORACLE_HOME/user_projects /域/ wl_server /配置/ AppConfig的

放在属性文件命名为commonConfig。性能 i在它的旁边。

也有编辑的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) 

任何人有任何合适的解决这个?

回答

0
<bean id="commonProps" 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations" value="classpath*:config/appConfig/commonConfig"/> 
</bean> 

以上配置在weblogic服务器上成功运行。

相关问题