EL1008E:(pos 0):在“ config.BeanExpressionContext”类型的对象上找不到属性或字段“ schedulerProperties”-可能不是公共的吗?

时间:2018-06-26 09:58:41

标签: spring spring-boot spring-batch

我正在从事Spring Batch项目。在这个项目中,我面临以下问题。我在项目中使用了计划任务,但不确定如何在main方法中设置参数?

如何解决此错误?如何传递不同的值?

<task:scheduled-tasks>
    <task:scheduled ref="KKKKScheduler" method="updateCache" cron="#{schedulerProperties['YYYY.cron.expression']}" />
</task:scheduled-tasks>

另一个代码段

<bean id="KKKKItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step">
    <property name="dataSource" ref="edsDataSource" />
    <property name="verifyCursorPosition" value="false" />
    <property name="fetchSize" value="200" />
    <property name="sql">
        <value>
        <![CDATA[
            SELECT XXXXXXXXXXXXXXXXXXXXX 
            ]]>
        </value>
    </property>

    <property name="rowMapper">
        <bean class="com.test.mapper.XXXRowMapper" />
    </property>
    <property name="preparedStatementSetter" ref="statementSetter" />
</bean>

<bean id="statementSetter" class="org.springframework.batch.core.resource.ListPreparedStatementSetter" scope="step">
    <property name="parameters">
        <list>
            <value>#{stepExecutionContext[payment]}</value>
            <value>#{stepExecutionContext[days]}</value>
        </list>
    </property>
</bean>


<bean id="customerFileGenerationPartitioner" class="com.test.partitioner.XXXXXXPartitioner" scope="step">
    <property name="executionContext" value="#{stepExecution.jobExecution.executionContext}"></property>
</bean>

错误

Exception in thread "main" org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'schedulerProperties' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
    at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:164)
    at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1418)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.doEvaluate(BeanDefinitionValueResolver.java:255)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:228)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:204)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init

如何在下面的代码中传递计划的任务的详细信息?

PropertyConfigurator.configure("src/main/resources/log4j.properties");

    String[] springConfig = { "C:\\META-INF\\spring\\KKK-job.xml" };

    ApplicationContext context = new FileSystemXmlApplicationContext(springConfig);
    JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job job = (Job) context.getBean("YYYJob");

    try {
        JobExecution execution = jobLauncher.run(job, new JobParameters());
        System.out.println("Exit Status : " + execution.getStatus());

    } catch (Exception e) {
        e.printStackTrace();
    }
}

0 个答案:

没有答案