Hi everyone,
I have such a similar problem. My project is a Spring Boot with Gradle as a dependency manager. I included PdfBox dependency in my “build.gradle” file, but from my app I’m not able to use its classes since they “cannot be resolved”. I don’t know what’s wrong with my files.
Here is my build.gradle
plugins {
id 'org.springframework.boot' version '2.3.0.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.demo'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web-services') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
implementation 'commons-io:commons-io:2.7'
implementation 'commons-codec:commons-codec:1.14'
compileOnly 'com.googlecode.xades4j:xades4j:1.5.1'
compileOnly 'org.projectlombok:lombok'
compileOnly 'org.apache.pdfbox:pdfbox:2.0.20'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
Then I try to do this in my java app
PDDocument doc = PDDocument.load(pdfFile);
And it shows me “PDDocument cannot be resolved”. What am I doing wrong? please help.
@shiroukamui You are using compileOnly 'org.apache.pdfbox:pdfbox:2.0.20' so the classes are not available in your code. You need to use implementation instead.