0

我在安排石英时遇到此错误。计划正在启动,但在创建 bean 时它在data-source-context.xml文件中失败。

我是否需要为环境声明任何值为 oracle 的系统变量?

数据源上下文.xml 文件

<bean id="environment" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="java.lang.System" />
<property name="targetMethod" value="setProperty" />
<property name="arguments">
<list>
    <value>environment</value>
    <bean class="java.lang.System" factory-method="getProperty">
        <constructor-arg>
     <value>environment</value>
    </constructor-arg>
<!-- The default value of the environment property -->
    <constructor-arg>
     <value>oracle</value>
    </constructor-arg>
    </bean>
</list>
</property>
</bean>

安慰:

Jan 2, 2013 4:06:00 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@4a804a80: display name [org.springframework.context.support.ClassPathXmlApplicationContext@4a804a80]; startup date [Wed Jan 02 16:06:00 GMT+05:30 2013]; root of context hierarchy
Jan 2, 2013 4:06:00 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [DWH/DWH-config.xml]
Jan 2, 2013 4:06:00 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [global-config.xml]
Jan 2, 2013 4:06:00 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [data-source-context.xml]
Jan 2, 2013 4:06:00 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@4a804a80]: org.springframework.beans.factory.support.DefaultListableBeanFactory@24152415
Jan 2, 2013 4:06:00 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@24152415: defining beans [dataSource,sessionFactory,transactionManager,environment,overrideProperties,placeholderProperties,lobHandler,incrementerParent,tm,jobRegistryBeanPostProcessor,jobRegistry,jobRepository,mapJobInstanceDao,mapJobExecutionDao,mapStepExecutionDao,jdbcTemplate,jobLauncher,essJob,essStep,essSkipStep,backOff,customEditorConfigurer,DWHDailyJob,initTask,directory,reader,dbWriter,skiplis,exitTask,inpFile,clean,cleanUpTask,temp]; root of factory hierarchy
[DWHMJobDetail] Job Terminated in error:
**    org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'environment' defined in class path resource [data-source-context.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException    **
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
    at 
4

1 回答 1

0

看起来你还没有在 JVM 中设置环境。在 JVM 设置中指定您的环境,例如

-DTEST.ENVIRONMENT=test
于 2013-01-02T13:21:24.547 回答