You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JPAStreamer集成后target/generated-sources下生成类无法访问求助

JPAStreamer生成类截图

我正尝试在项目中集成JPAStreamer,按预期构建项目后应当生成格式为ClassName$的类,目前类已成功生成但无法访问使用。我已将target/generated-sources/annotations设为源码文件夹,也未设置任何排除规则,但问题仍未解决。

问题排查及解决方案

  • 检查注解处理器依赖配置
    确保构建文件中JPAStreamer的核心依赖和注解处理器依赖版本完全匹配,没有缺失注解处理器配置。
    Maven配置参考:
    <dependencies>
      <dependency>
          <groupId>com.speedment.jpastreamer</groupId>
          <artifactId>jpastreamer-core</artifactId>
          <version>对应版本号</version>
      </dependency>
    </dependencies>
    
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1及以上</version>
          <configuration>
            <annotationProcessorPaths>
              <path>
                <groupId>com.speedment.jpastreamer</groupId>
                <artifactId>jpastreamer-processor</artifactId>
                <version>和core依赖完全相同的版本号</version>
              </path>
            </annotationProcessorPaths>
          </configuration>
        </plugin>
      </plugins>
    </build>
    
    Gradle配置参考:
    dependencies {
      implementation 'com.speedment.jpastreamer:jpastreamer-core:对应版本号'
      annotationProcessor 'com.speedment.jpastreamer:jpastreamer-processor:和core完全相同的版本号'
    }
    
  • 清理IDE缓存重新构建
    IDE经常会出现源码目录识别缓存问题,以IDEA为例:
    1. 点击顶部菜单File -> Invalidate Caches...
    2. 勾选清理文件系统缓存、清理下载的共享索引,点击重启IDE
    3. 重启后执行mvn clean compile(Maven)或gradle clean compileJava(Gradle)重新构建项目
  • 检查实体类注解
    确认所有需要生成元类的JPA实体都正确添加了@Entity注解,没有拼写错误,包路径不存在中文、特殊字符等异常情况。
  • 检查调用类的包路径和导包配置
    生成的ClassName$类默认和原实体类在同一个包下,确认调用时导入了正确的全限定类名,类名后缀是美元符号$没有写错。
  • 检查构建参数
    确认构建命令中没有添加-proc:none参数(该参数会跳过注解处理器执行),也没有配置任何针对target/generated-sources目录的排除规则。

内容的提问来源于stack exchange,提问作者vh1ne

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 15:54:05