Параметр 0 конструктора требовал bean-компонента типа java.lang.String, который не удалось найти.JAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Параметр 0 конструктора требовал bean-компонента типа java.lang.String, который не удалось найти.

Сообщение Anonymous »

Я работаю над пакетом Spring с приложением Spring Boot 2.X, на самом деле его существующий код я извлек из git. При запуске приложения происходит сбой из-за ошибки ниже только у меня, и тот же код работает у других.

s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inputItemReader' defined in file [C:\Users\XYZ\git\main\batch\CBatchProcessing\target\classes\com\main\batchprocessing\batch\reader\InputItemReader.class]: Unsatisfied dependency expressed through **constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations**: {}

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-16 23:23:37.411 ERROR 2384 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

**Parameter 0 of constructor in com.main.batchprocessing.batch.reader.InputItemReader required a bean of type 'java.lang.String' that could not be found.**

Action:

Consider defining a bean of type 'java.lang.String' in your configuration.


Я проверил ниже
  • Все компоненты Spring правильно аннотированы с помощью @Component , @Service, @Controller, @Repository и т. д.
  • @ComponentScan и @EnableAutoCONfiguration также предоставляются.
  • Пытался указать «java. lang.String" в объявлениях.
Код:

import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.mapping.JsonLineMapper;
import
org.springframework.batch.item.file.separator.JsonRecordSeparatorPolicy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.FileSystemResource;
import org.springframework.stereotype.Component;

@Component
public class InputItemReader extends FlatFileItemReader implements StepExecutionListener {

@Autowired
private InputFileHeaderValidator inputFileHeaderValidator;

@Autowired
private FileAuditService fileAuditService;

private final Logger log =
LoggerFactory.getLogger(InputItemReader.class);

private java.lang.String inputFilePath;

public InputItemReader(String inputFilePath) {
setLineMapper(new JsonLineMapper());
setRecordSeparatorPolicy(new JsonRecordSeparatorPolicy());
setResource(new FileSystemResource(inputFilePath));
this.inputFilePath = inputFilePath;
}
}


Подробнее здесь: https://stackoverflow.com/questions/528 ... ng-that-co
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»