由于环境属性的原因,Spring Boot Batch应用程序无法在特定环境中启动

0 人关注

我在几个Linux环境中运行批处理程序。该应用程序在其中一个环境中工作,在另一个环境中失败。我在那个环境中得到以下失败信息。这个环境有一些参数,似乎阻碍了应用程序的启动。需要做什么来改变它,使应用程序工作。

我检查了属性文件,发现这个参数 'ENV=int'。 我想这可能是导致问题的一次。

Error StackTrace: {'timestamp':'2022-09-13 06:17:44,381','level':' WARN','transactionId':', 'userId':', 'env':', 'src_host':', 'appId':', 'className':', 'methodName':', 'messageId]:', 'essage': 'Exception encountered during context initialization - canceling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException。创建名称为'btchJobLauncher'的bean时出错。通过字段'jobs'表达的依赖性未得到满足;嵌套的异常是 org.springframework.beans.factory.UnsatisfiedDependencyException。创建名称为'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration'的 bean 时出错。通过字段'dataSource'表达的依赖性未得到满足;嵌套的异常是 org.springframework.beans.factory.UnsatisfiedDependencyException。创建名称为'cmnCnfg'的bean时出错。通过字段'cnfgReader'表达的依赖性未得到满足;嵌套的异常是 org.springframework.boot.context.properties.ConfigurationPropertiesBindException。创建名为'cnfgReader'的bean时出错。Could not bind properties to 'CnfgReader' : prefix=, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException:将'env'下的属性绑定到org.springframework.core.env.Env'}时失败。 {'timestamp':'2022-09-13 06:17:44,403', 'level':' INFO', 'transactionId':', 'userId':', 'env' :', 'src_host':', 'appId':', 'className':', 'methodName':', 'messageId':', 'message': 启动ApplicationContext错误。要显示条件报告,请在启用'调试'后重新运行你的应用程序。'} {'timestamp':'2022-09-13 06:17:44,440', 'level':'ERROR', 'transactionId':', 'userId':', 'env':', 'src_host':', 'appId':', 'className':', 'methodName':', 'messageId':', ' message':'

应用程序未能启动

将'env'下的属性绑定到org.springframework.core.env.Environment时失败。 属性:env 值:int 起源:来自属性源 "systemEnvironment "的 "ENV" 原因:org.springframework.core.convert.ConverterNotFoundException。没有找到能够从类型[java.lang.String]转换到类型[org.springframework.core.env.Environment]的转换器。 更新你的应用程序的配置。

我已经添加了堆栈跟踪所指向的问题的代码块。

@Configuration
@EnableConfigurationProperties
@ConfigurationProperties
@PropertySource(value = "file:${PROPS_FILE:cnfg/BtchDb.properties}")
@Component
public class CnfgReader {
    @Autowired
    private Environment envt;
    public Environment getEnvt() {
        return envt;
    public void setEnvt(Environment envt) {