gpt4 book ai didi

eclipse - M2E 并让 Maven 生成源文件夹作为 Eclipse 源文件夹

转载 作者:行者123 更新时间:2023-12-03 05:02:53 25 4
gpt4 key购买 nike

我在 Eclipse 中有一个 Maven 项目,并且有运行注释处理器来生成代码的 Maven 目标。此代码的输出文件夹是 target/generated-sources/apt

为了让 Eclipse 看到生成的代码,我需要将 target/generated-sources/apt 作为源文件夹添加到 Eclipse 项目中。

但是,这会导致出现“Maven 配置问题”类型的错误

Project configuration is not up-to-date with pom.xml. Run projectconfiguration update

我想我明白为什么会出现这种情况,因为 Eclipse 有一组与 Maven 不同的源文件夹。但我需要这个不同的集合,因为我需要 Eclipse 才能看到生成的源文件夹...

当进行纯 Maven 构建时,这些源文件夹将由 Maven 包含在构建中。

顺便说一句,我已经升级到 Maven Eclipse 插件的官方 Eclipse 版本 m2e 1.0 - 以前是 m2eclipse。我想看看在必须返回到旧的 m2eclipse 版本之前是否可以使用 m2e 插件找到解决方案/解决方案。

最佳答案

您需要将源目录附加到 build-helper-plugin .

像这样:

 <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/java/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

您还需要:

关于eclipse - M2E 并让 Maven 生成源文件夹作为 Eclipse 源文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7160006/

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