gpt4 book ai didi

java - cassandra datastax 写入生成的代码时出现意外错误 : java. lang.NullPointerException

转载 作者:行者123 更新时间:2023-12-04 15:22:43 26 4
gpt4 key购买 nike

我有一个java类

import com.datastax.oss.driver.api.mapper.annotations.Dao;
import com.datastax.oss.driver.api.mapper.annotations.Delete;
import com.datastax.oss.driver.api.mapper.annotations.Insert;
import com.datastax.oss.driver.api.mapper.annotations.Select;

@Dao
public interface ProductDao {
@Select
Product findById(UUID productId);

@Insert
void save(Product product);

@Delete
void delete(Product product);
}

我想用它来获取 cassandra 记录。我正在尝试文档 - https://github.com/datastax/java-driver/tree/4.x/manual/mapper当我尝试用 Maven 构建它时,我得到了一个 NPE

ProductDao.java:[10,8] Unexpected error while writing generated code: java.lang.NullPointerException
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.util.HierarchyScanner.traverseHierarchy(HierarchyScanner.java:169)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.util.HierarchyScanner.resolveHierarchyScanStrategy(HierarchyScanner.java:97)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.util.HierarchyScanner.resolveTypeHierarchy(HierarchyScanner.java:81)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.entity.DefaultEntityFactory.getDefinition(DefaultEntityFactory.java:80)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.dao.DaoSelectMethodGenerator.generate(DaoSelectMethodGenerator.java:98)
[ERROR] at java.util.Optional.flatMap(Optional.java:241)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.dao.DaoImplementationGenerator.getContents(DaoImplementationGenerator.java:331)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.SingleFileCodeGenerator.generate(SingleFileCodeGenerator.java:43)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.MapperProcessor.processAnnotatedTypes(MapperProcessor.java:125)
[ERROR] at com.datastax.oss.driver.internal.mapper.processor.MapperProcessor.process(MapperProcessor.java:90)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:802)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:523)
[ERROR] at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
[ERROR] at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
[ERROR] at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
[ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
[ERROR] at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:943)
[ERROR] at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:137)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

无法找出错误的根源,欢迎任何帮助。

最佳答案

堆栈跟踪中的这一行从 - 开始向上

[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.entity.DefaultEntityFactory.getDefinition(DefaultEntityFactory.java:80)

向我指出这是实体类的问题,而不是 Dao 本身。考虑到这一点,我可以通过删除 Dao 要返回的类上的 @Entity 注释来复制此堆栈跟踪,在您的情况下,该类将是 Product。

我的预期是 Product 类未正确注释,我们需要从该类添加代码以进一步诊断/确认。

关于java - cassandra datastax 写入生成的代码时出现意外错误 : java. lang.NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62969759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com