我正在使用Apache avro生成一些pojos,所有这些在运行中都工作得很好,只是生成的源代码在IDE (intellij)的imports中被标记为不存在。
我尝试使用build- helper - maven -plugin来添加源代码,但它不起作用这是我对apache avro和build helper插件的maven配置:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
<configuration>
<stringType>String</stringType>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/</outputDirectory>
<imports>
<import>${project.basedir}/src/main/avro/errorkind.avsc</import>
</imports>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>发布于 2021-04-16 00:03:16
"generated-sources“也位于${project.build.directory}/target文件夹下,尝试将"generated-sources”标记为源目录。您可以通过以下方式完成此操作:
Project Structure→Modules→单击generated-sources文件夹,使其成为源文件夹。
https://stackoverflow.com/questions/66919291
复制相似问题