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 找到了一个旧的错误跟踪,但我没有看到与我的问题的相关性。

感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)