父Maven项目在使用IDEA进行编译时出现错误,但模块编译没有问题

时间:2019-01-10 14:08:41

标签: java maven intellij-idea

我的问题是:当我从命令行运行“ mvn程序包”时,它可以很好地编译,但是当我在IntelliJ IDEA(2018.3.2)中重建项目时,它给出了数百个错误,提示“ blah blah程序包不存在”或“找不到符号等等”。

我的Maven结构由一个父pom组成,该pom具有4个引用父pom的子模块(假设为A,B,C,D)。模块A引用B和C。B和C每个引用D。父级的包装设置为“ pom”,四个模块的包装设置为“ jar”。我正在使用maven-dependency-plugin将B,C,D打包到A的输出中。

这一点必须很重要:当我在IDEA的项目浏览器中右键单击任何项​​目(A,B,C或D)并单击“重建”时,每个构建都没有问题。当我右键单击父项目并单击“重建”(或简单地按Ctrl + Shift + F9)时,我得到了有关未找到的程序包或符号的错误。给出错误的源文件在模块A下,正如我自己所说,该模块可以毫无问题地编译。

更多内容:模块A的所有依赖项(自然)在模块A的pom下定义。如果我将依赖关系移到父pom,问题就会消失并且每个人都可以正常编译,但是当我将依赖关系移回模块A的pom时,问题再次出现。

我不知道为什么模块A可以自行编译,为什么父pom试图编译模块A的源代码。

我已经在stackoverflow上找到了类似的问题,关于Maven编译没有问题,但是IDEA给出了错误,试图重新导入,重新索引,使缓存无效。所提出的解决方案均未解决我的问题。

欢迎任何建议

编辑:这是我正在使用的pom.xml。 (抱歉,我无法正确渲染项目标签)

相信模块B,C和DI的

pom在此阶段不相关,因为我意识到此错误发生在某个版本的代码中,其中模块A不包括依赖于模块B,C或D的代码。以下是pom导致此错误的.xml文件以及模块B,C和D不在画面中。

此外,使用与Atlassian插件SDK(即Maven 3.2.1)捆绑在一起的Maven

父pom.xml

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/maven-v4_0_0.xsd“>              tr.com.my-organization.sdlc.pom         根绒球         3.1.0     

<modelVersion>4.0.0</modelVersion>
<groupId>tr.com.my-organization</groupId>
<artifactId>my-project-aggregator</artifactId>
<packaging>pom</packaging>
<version>2.1.0.1</version>
<modules>
    <module>moduleD</module>
    <module>moduleC</module>
    <module>moduleB</module>
    <module>moduleA</module>
</modules>
<name>My Project Aggregator POM</name>
<properties>
    <dep.amps.version>5.0.3</dep.amps.version>
    <dep.jira.version>7.0.0</dep.jira.version>
    <buildNumber>1</buildNumber>
    <pkg.build.javaVersion>1.8</pkg.build.javaVersion>
    <dep.httpclient.version>4.3.4</dep.httpclient.version>
    <dep.testkit.version>5.2.26</dep.testkit.version>
    <dep.servlet.version>2.4</dep.servlet.version>
    <dep.junit.version>4.10</dep.junit.version>
    <dep.javax.version>1.1.1</dep.javax.version>
    <dep.gson.version>2.3</dep.gson.version>
    <dep.slf4j.version>1.6.6</dep.slf4j.version>
    <dep.mockito.version>1.8.5</dep.mockito.version>
    <dep.template.version>1.3.1</dep.template.version>
    <dep.springosgi.version>1.1.3</dep.springosgi.version>
    <dep.springcontext.version>2.5.6.SEC02</dep.springcontext.version>
    <dep.ao.version>0.19.7</dep.ao.version>
    <dep.commons-lang.version>2.4</dep.commons-lang.version>
    <dep.jira-greenhopper.version>6.4.1</dep.jira-greenhopper.version>
    <upm.license.compatibility.version>2.0.1</upm.license.compatibility.version>
    <sal.api.version>2.4.0</sal.api.version>        
    <useFastdevCli>false</useFastdevCli>
</properties>

<profiles>
    <profile>
        <id>default</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>bamboo</id>
        <properties>
            <buildNumber>${bambooBuildNumber}</buildNumber>
        </properties>
    </profile>
</profiles>

模块A的pom.xml

    <?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“>              tr.com.my-organization         我的项目汇总器         2.1.0.1         ../     

<modelVersion>4.0.0</modelVersion>
<artifactId>moduleA</artifactId>
<packaging>atlassian-plugin</packaging>

<properties>
    <pkg.build.javaVersion>1.8</pkg.build.javaVersion>
    <dep.httpclient.version>4.3.4</dep.httpclient.version>
    <dep.testkit.version>5.2.26</dep.testkit.version>
    <dep.servlet.version>2.4</dep.servlet.version>
    <dep.junit.version>4.10</dep.junit.version>
    <dep.javax.version>1.1.1</dep.javax.version>
    <dep.gson.version>2.3</dep.gson.version>
    <dep.slf4j.version>1.6.6</dep.slf4j.version>
    <dep.mockito.version>1.8.5</dep.mockito.version>
    <dep.template.version>1.3.1</dep.template.version>
    <dep.springosgi.version>1.1.3</dep.springosgi.version>
    <dep.springcontext.version>2.5.6.SEC02</dep.springcontext.version>
    <dep.ao.version>0.19.7</dep.ao.version>
    <dep.commons-lang.version>2.4</dep.commons-lang.version>
    <dep.jira-greenhopper.version>6.4.1</dep.jira-greenhopper.version>
    <upm.license.compatibility.version>2.0.1</upm.license.compatibility.version>
    <sal.api.version>2.4.0</sal.api.version>
    <useFastdevCli>false</useFastdevCli>
</properties>

<dependencies>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-api</artifactId>
        <version>${dep.jira.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.osgi</groupId>
        <artifactId>spring-osgi-core</artifactId>
        <version>${dep.springosgi.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${dep.springcontext.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${dep.junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
        <version>1.2.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>${dep.javax.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.2-atlassian-1</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>${dep.servlet.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${dep.slf4j.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>${dep.httpclient.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>${dep.mockito.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.templaterenderer</groupId>
        <artifactId>atlassian-template-renderer-api</artifactId>
        <version>${dep.template.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>${dep.commons-lang.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.jira.plugins</groupId>
        <artifactId>jira-greenhopper-plugin</artifactId>
        <version>${dep.jira-greenhopper.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.activeobjects</groupId>
        <artifactId>activeobjects-plugin</artifactId>
        <version>${dep.ao.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.upm</groupId>
        <artifactId>licensing-api</artifactId>
        <version>${upm.license.compatibility.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.upm</groupId>
        <artifactId>upm-api</artifactId>
        <version>${upm.license.compatibility.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.sal</groupId>
        <artifactId>sal-api</artifactId>
        <version>${sal.api.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-jira-plugin</artifactId>
            <version>${dep.amps.version}</version>
            <extensions>true</extensions>
            <configuration>
                <productVersion>${dep.jira.version}</productVersion>
                <productDataVersion>${dep.jira.version}</productDataVersion>
                <enableQuickReload>true</enableQuickReload>
                <enableFastdev>false</enableFastdev>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-storage-plugin</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                        <includeArtifactIds>plugin-license-storage-plugin</includeArtifactIds>
                        <stripVersion>true</stripVersion>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

0 个答案:

没有答案