2

Maven 在编译器尝试生成 jpa 实体时失败。

Gender_.java:[11,50] cannot find symbol Gender

这两个类都存在。Gender 类存在于 kaptStubs 目录中,Gender_ 存在于 kapt 目录中。

起居室:

            <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <version>${kotlin.version}</version>
            <executions>
                <execution>
                    <id>kapt</id>
                    <goals>
                        <goal>kapt</goal>
                    </goals>
                    <configuration>
                        <sourceDirs>
                            <sourceDir>src/main/kotlin</sourceDir>
                            <sourceDir>src/main/java</sourceDir>
                        </sourceDirs>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <jvmTarget>1.8</jvmTarget>
                <compilerPlugins>
                    <plugin>all-open</plugin>
                    <plugin>spring</plugin>
                    <plugin>jpa</plugin>
                </compilerPlugins>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-noarg</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-allopen</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
            </dependencies>
        </plugin>
4

1 回答 1

1

尝试添加annotationProcessorPaths到 kapt 配置

<plugin>
  <groupId>org.jetbrains.kotlin</groupId>
  <artifactId>kotlin-maven-plugin</artifactId>
  <version>${kotlin.version}</version>
  <configuration>
      <sourceDirs>
          <sourceDir>src/main/kotlin</sourceDir>
          <sourceDir>src/main/java</sourceDir>
      </sourceDirs>
  </configuration>
  <executions>
      <execution>
          <id>kapt</id>
          <goals>
              <goal>kapt</goal>
          </goals>
          <configuration>
              <annotationProcessorPaths>
                  <annotationProcessorPath>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-jpamodelgen</artifactId>
                      <version>${version.hibernate}</version>
                  </annotationProcessorPath>
              </annotationProcessorPaths>
          </configuration>
      </execution>
      <execution>
          <id>compile</id>
          <phase>process-sources</phase>
          <goals>
              <goal>compile</goal>
          </goals>
      </execution>
      <execution>
          <id>test-compile</id>
          <phase>process-test-sources</phase>
          <goals>
              <goal>test-compile</goal>
          </goals>
      </execution>
  </executions>
</plugin>
于 2019-09-03T10:12:12.963 回答