When building below Spring session sample using gradle: https://docs.spring.io/spring-session/docs/current/reference/html5/guides/boot-findbyusername.html
I encountered an error regarding to java.annotation module, anybody have idea how to resolve that?
/spring-session/spring-session-core/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java:22: error: package javax.annotation is not visible
import javax.annotation.PostConstruct;
^
(package javax.annotation is declared in module java.xml.ws.annotation, which is not in the module graph)
warning: unknown enum constant When.MAYBE
reason: class file for javax.annotation.meta.When not found
1 error
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':spring-session-core:compileJava'.
> Compilation failed; see the compiler error output for details.
I tried to add below config in build.gradle however the problem remain.
tasks.withType(AbstractCompile) {
options.compilerArgs += ["--add-modules", "java.xml.bind"]
}
tasks.withType(Test) {
jvmArgs += ["--add-modules", "java.xml.bind"]
}
I was getting the same error:
warning: unknown enum constant When.MAYBE
reason: class file for javax.annotation.meta.When not found
For me it was becuase I had annotation processing with lombok
which wasn't picked-up with the project dependencies.
In the end I added annotationProcessor
as part of the dependencies as follows:
dependencies {
// ...
compile('org.springframework.boot:spring-boot-starter-web')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
// ...
annotationProcessor('org.projectlombok:lombok')
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With