首页 > 解决方案 > IntelliJ Idea 忽略 Maven 默认配置文件

问题描述

我试图说服我的层次结构从 Eclipse 切换到 IntelliJ,所以我选择使用社区版本打开一个 maven 项目。在这个 maven 项目中,除非激活特定配置文件,否则应该从编译中排除一个文件。

这在 Eclipse 上运行良好,但 IntelliJ Idea 对此感到窒息,无论是“付费”(我下载并可以尝试一段时间)或社区版本(最新版本,2020.3.2)

这个 pom.xml 提取显示了两个配置文件,其中一个默认处于活动状态。此默认配置文件从编译中排除了一个文件,但 IntelliJ 没有注意到它并尝试编译它,即使尚未加载所需的依赖项(最后与 pom 配置文件一致?)

<profiles>
    <profile>
        <id>use-eobjects</id>
        <properties>
            <sas.impl>com.xxx.dataLib.sasfiles.SASEObjectsImpl</sas.impl>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude>**/SASEpamImpl.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.eobjects.metamodel-extras</groupId>
                <artifactId>MetaModel-extras-sas</artifactId>
                <version>4.3.2</version>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>use-epam</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <sas.impl>com.xxx.dataLib.sasfiles.SASEpamImpl</sas.impl>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude>**/SASEOjbectsImpl.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>com.epam</groupId>
                <artifactId>parso</artifactId>
                <version>2.0</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    </profile>
</profiles>

我在这里找到了一个旧的错误跟踪https://youtrack.jetbrains.com/issue/IDEA-97932但我看不到与我的问题的相关性。

谢谢你的帮助。

标签: intellij-ideamaven-profiles

解决方案


推荐阅读