maven - 在 maven 中定义额外的源目录

标签 maven intellij-idea code-generation

我从 wsdl 文件生成 Java 源代码。这些源不受版本控制(但 wsdl 是)。我们使用maven中的cxf-codegen-plugin,生成的类在<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>中生成.

这在 Maven 中一切正常。

我必须将此目录定义为 Intelij Idea 中的附加源目录。 ( target 通常被排除在外)。

但是每次我将maven项目重新导入InteliJ Idea(由于pom变化),我必须手动编辑Idea中的项目结构并重新定义添加源目录。

有什么方法可以在 maven 中定义这个额外的源目录,以便 Idea 在重新加载时选择它,或者告诉 Idea 不要忘记手动源目录定义?

最佳答案

此案例在 IntelliJ IDEA Maven FAQ 中有所描述。 , 生成源 部分:

Specify the directory of your source root when you reimport a project.
You can select one of the following options:

  • Detect automatically This is a default option. When you select this option, IntelliJ IDEA automatically detects the location of the generated sources. IntelliJ IDEA also detects which directory to mark as a source root. However, IntelliJ IDEA searches for the generated sources only in target/generated-sources and target/generated-sources/* directories.

  • target/generated-sources This option enables you to mark the directory as source root manually.

  • subdirectories of "target/generated-sources" This option enables you to mark a subdirectory as a source root manually.

  • Don't detect This option lets you skip the detection process.

关于maven - 在 maven 中定义额外的源目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10735380/

相关文章:

java - 将java库添加到Maven中

java - 从 jar 文件导入一个类到 IntelliJ

Haskell 相当于 C 的 __LINE__

java - 在运行时创建带有注释字段的 java 类

asp.net - 导出PhoneGap的ASP.NET MVC应用程序源代码

maven - 一个 Maven 配置文件可以从另一个 Maven 配置文件继承吗?

maven - 在 IntelliJ 中运行 Gulp 和 Redploy

java - IntelliJ 更改为 Debug模式的字符串(变量 View )

JavaFX 11 : IllegalAccessError when creating Label

java - Maven:我的项目有一个不在任何 Maven 仓库(系统范围)中的依赖项。它会包含在我的最终 jar 中吗?