AspectJ Weaver & java 模块系统 (spring + gradle),编译问题

AspectJ Weaver & java module system (spring + gradle), problem with compilation

我使用 spring 5、Java 10 和 Gradle 4.8

我面临以下问题:

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

我读到堆栈溢出补充:

compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.9.1'

但是,当我这样做时,出现 100 个错误,例如:

error: module java.persistence reads package org.aspectj.internal.lang.reflect from both aspectjrt and org.aspectj.weaver

如何解决这个问题?

依赖关系:

compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.5'
compile group: 'org.springframework', name: 'spring-core', version: '5.0.7.RELEASE'
compile group: 'org.springframework', name: 'spring-context', version: '5.0.7.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '5.0.7.RELEASE'
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.1'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '2.0.8.RELEASE'
compile group: 'io.projectreactor', name: 'reactor-core', version: '3.1.8.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.0.6.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '5.0.6.RELEASE'

compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.1.Final'
compile group: 'org.hibernate', name: 'hibernate-hikaricp', version: '5.3.1.Final'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.10.Final'
compile group: 'org.glassfish', name: 'javax.el', version: '3.0.1-b08'
compile group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.6.2'

compile group: 'org.aspectj', name: 'aspectjrt', version: '1.9.1'
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.28'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
compile group: 'javax.activation', name: 'activation', version: '1.1.1'

问题是 spring-data-jpa 依赖于 aspectjrt 版本 1。8.x(我想)还没有为 java9 模块化做好准备。我将它排除在依赖项之外,并包含了 aspectjrt 和 weaver 的正确版本,现在它可以工作了。