0

I am following a tutorial on Spring batch and using jre7. In the Step function there is a line

return stepBuilderFactory.get("step1")
            .<Employee, EmployeeContribution>chunk(1) 
            .reader(flatFileItemReader())
            .processor(processor())
            .writer(writer())
            .build();

Here I get an error saying

java.util.function.Function cannot be resolved. It is indirectly referenced from required .class files.

The tutorial is also using jre7, how is it working for them and not for me?

Akash Srivastav
  • 756
  • 5
  • 15
  • Maybe duplicate of this question? https://stackoverflow.com/questions/5547162/eclipse-error-indirectly-referenced-from-required-class-files – pL4Gu33 May 29 '18 at 04:34
  • @pL4Gu33 How do I find out what it is missing? And the problem gets resolved if I add jre 1.8 to the build path (but another system that I'll be running it on runs jre 1.7, so I can't use 1.8 in this). – Akash Srivastav May 29 '18 at 04:43
  • Are you sure you're using the same Spring boot version in the tutorial as in your code? Spring boot 2.x requires Java 8 or higher, while Spring boot 1.x works on Java 7 as well. – g00glen00b May 29 '18 at 06:13

1 Answers1

2

java.util.Function is a part of the functional API introduced in Java 8. Starting with Spring boot 2.0, Java 8 is the minimum requirement when running Spring boot applications, as mentioned in the migration guide:

First, Spring Boot 2.0 requires Java 8 or later. Java 6 and 7 are no longer supported. It also requires Spring Framework 5.0.

If you want to use Java 7, make sure you're using Spring boot 1.x. My guess is also that the tutorial you were following is using Spring boot 1.x, while you're using Spring boot 2.x.

g00glen00b
  • 41,995
  • 13
  • 95
  • 133