尝试在项目中使用Java 9模块,通过Intellij构建时出现以下错误:
class Category(models.Model):
parent = models.ForeignKey('self', null=True, blank=True, on_delete=models.CASCADE)
name = models.CharField(max_length=255)
full_name = models.TextField() # Can also set this to be CharField and choose max_length according to level of hierarchy expected.
def save(self, *args, **kwargs):
if self.parent is not None:
self.full_name = self.parent.full_name + '.' + self.name # Not a top level category
else:
self.full_name = self.name # in case of a top level category
super().save(*args, **kwargs)
在我的pom.xml中,我确实有:
Information:java: java.lang.module.FindException: Unable to derive module descriptor for /Users/laurentthiebaud/.m2/repository/org/elasticsearch/elasticsearch/7.3.2/elasticsearch-7.3.2.jar
Information:java: at java.base/jdk.internal.module.ModulePath.readJar(ModulePath.java:647)
Information:java: at java.base/jdk.internal.module.ModulePath.readModule(ModulePath.java:330)
Information:java: at java.base/jdk.internal.module.ModulePath.scan(ModulePath.java:236)
Information:java: at java.base/jdk.internal.module.ModulePath.scanNextEntry(ModulePath.java:189)
Information:java: at java.base/jdk.internal.module.ModulePath.findAll(ModulePath.java:165)
Information:java: at java.base/java.lang.module.Resolver.findAll(Resolver.java:842)
Information:java: at java.base/java.lang.module.Resolver.bind(Resolver.java:223)
Information:java: at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:482)
Information:java: at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:288)
Information:java: at jdk.compiler/com.sun.tools.javac.file.JavacFileManager.getServiceLoader(JavacFileManager.java:985)
Information:java: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Information:java: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Information:java: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Information:java: at java.base/java.lang.reflect.Method.invoke(Method.java:566)
Information:java: at org.jetbrains.jps.javac.JavacMain$2.invoke(JavacMain.java:290)
Information:java: at com.sun.proxy.$Proxy25.getServiceLoader(Unknown Source)
Information:java: at com.sun.proxy.$Proxy26.getServiceLoader(Unknown Source)
Information:java: at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.initProcessorLoader(JavacProcessingEnvironment.java:261)
Information:java: at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.<init>(JavacProcessingEnvironment.java:237)
Information:java: at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.instance(JavacProcessingEnvironment.java:193)
Information:java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.initProcessAnnotations(JavaCompiler.java:1136)
Information:java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:922)
Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
Information:java: at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:195)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:460)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:330)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:255)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:213)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1324)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1004)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1071)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:965)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:794)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:376)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
Information:java: at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:139)
Information:java: at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:288)
Information:java: at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:121)
Information:java: at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:228)
Information:java: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
Information:java: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
Information:java: at java.base/java.lang.Thread.run(Thread.java:834)
Information:java: Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.lucene.search.suggest.document.Completion50PostingsFormat not in module
Information:java: at java.base/jdk.internal.module.ModulePath.deriveModuleDescriptor(ModulePath.java:554)
Information:java: at java.base/jdk.internal.module.ModulePath.readJar(ModulePath.java:643)
(7.3.2是最新版本)。
在我的模块信息中,我还有:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>7.3.2</version>
</dependency>
现在,当我使用Maven进行构建时,我会得到与git相同的结果:
requires elasticsearch;
是因为弹性与Java 9不兼容(请参阅https://github.com/elastic/elasticsearch/issues/38299)吗?我不应该因为这个原因使用模块,还是有任何解决方法?