I am a beginner just started learning Spring Batch. I followed this tutorial here to create a helloworld example. While I was following the tutorial, I encountered a problem when I was trying to import org.springframework.batch.item.ItemProcessor
into a java class. Hence I searched online and found out that I need to add something inside the build.gradle. The problem was, even though I have added the org.springframework.batch:spring-batch-core
dependency in build.gradle, I was still having error message for the import. I am using Eclipse Java EE IDE 4.5.0 (Mars) to do this tutorial and have installed the Spring Test Suite (by following the tutorial). I have also tried right clicking the project and choose the "refresh" option but the error message is still there.
Additional note: I have also tried to follow the answer stated here but I cannot find the "Refresh Dependencies" in the "Gradle" context menu. How do you even know that the build.gradle is working?
Below is my code (Java class) that imports the Spring Batch:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//error message: "the import org.springframework.batch cannot be resolved"
import org.springframework.batch.item.ItemProcessor;
//error message: "ItemProcessor cannot be resolved to a type"
public class PersonItemProcessor implements ItemProcessor<Person, Person> {
@Override
public Person process(final Person person) throws Exception {
//some codes
}
}
Below is the build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-consuming-rest'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.batch:spring-batch-core") //added by me
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-web")
compile("com.fasterxml.jackson.core:jackson-databind")
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}