为什么我的多模块Maven项目中的一个模块无法正常工作?

huangapple go评论59阅读模式
英文:

Why a module in my multi-module maven project doesn't work?

问题

我从远程仓库获取了一个项目。结果,我有一个包含3个模块的项目,这些模块运行良好,但是有一个模块似乎不是项目的一部分,或者说有些问题。

这是项目的截图:
为什么我的多模块Maven项目中的一个模块无法正常工作?

所以 anagram、calculator 和 char counter 运行良好,但是 java-8-api 不工作。

这是根目录的 pom.xml:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foxminded</groupId>
    <artifactId>foxminded-project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>anagram</module>
        <module>calculator</module>
        <module>char-counter</module>
        <module>java-8-api</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>9</maven.compiler.target>
        <maven.compiler.source>9</maven.compiler.source>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- 依赖声明 -->
        </dependencies>
    </dependencyManagement>

    <build>
        <!-- 构建配置 -->
    </build>

</project>

这是 java-8-api 模块的 pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.foxminded</groupId>
        <artifactId>foxminded-project</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>java-8-api</artifactId>
    <dependencies>
        <!-- 依赖声明 -->
    </dependencies>
</project>

非常感谢任何帮助。

英文:

I fetched a project from a remote repo. As a result, I have a project with 3 modules that work fine and one module that somehow is not a part of the project or something.
Here is the screenshot of my project:
为什么我的多模块Maven项目中的一个模块无法正常工作?

So anagram, calculator and char counter work well, but java-8-api does not.

Here is the root pom.xml:

&lt;project xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.foxminded&lt;/groupId&gt;
    &lt;artifactId&gt;foxminded-project&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;

    &lt;modules&gt;
        &lt;module&gt;anagram&lt;/module&gt;
        &lt;module&gt;calculator&lt;/module&gt;
        &lt;module&gt;char-counter&lt;/module&gt;
        &lt;module&gt;java-8-api&lt;/module&gt;
    &lt;/modules&gt;

    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;maven.compiler.target&gt;9&lt;/maven.compiler.target&gt;
        &lt;maven.compiler.source&gt;9&lt;/maven.compiler.source&gt;
    &lt;/properties&gt;

    &lt;dependencyManagement&gt;
        &lt;dependencies&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
                &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
                &lt;version&gt;5.5.2&lt;/version&gt;
                &lt;scope&gt;test&lt;/scope&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
                &lt;artifactId&gt;junit-jupiter-params&lt;/artifactId&gt;
                &lt;version&gt;5.4.2&lt;/version&gt;
                &lt;scope&gt;test&lt;/scope&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;org.mockito&lt;/groupId&gt;
                &lt;artifactId&gt;mockito-junit-jupiter&lt;/artifactId&gt;
                &lt;version&gt;2.23.4&lt;/version&gt;
                &lt;scope&gt;test&lt;/scope&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;junit&lt;/groupId&gt;
                &lt;artifactId&gt;junit&lt;/artifactId&gt;
                &lt;version&gt;4.11&lt;/version&gt;
                &lt;scope&gt;test&lt;/scope&gt;
            &lt;/dependency&gt;
        &lt;/dependencies&gt;
    &lt;/dependencyManagement&gt;

    &lt;build&gt;
        &lt;pluginManagement&gt;
            &lt;plugins&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.22.0&lt;/version&gt;
                &lt;/plugin&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.22.0&lt;/version&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/pluginManagement&gt;
        
    &lt;/build&gt;

&lt;/project&gt;

Here is the java-8-api pom.xml:

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;parent&gt;
    &lt;groupId&gt;com.foxminded&lt;/groupId&gt;
    &lt;artifactId&gt;foxminded-project&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;/parent&gt;
  &lt;artifactId&gt;java-8-api&lt;/artifactId&gt;
  &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
            &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
            &lt;scope&gt;test&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.mockito&lt;/groupId&gt;
            &lt;artifactId&gt;mockito-junit-jupiter&lt;/artifactId&gt;
            &lt;scope&gt;test&lt;/scope&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/project&gt;

Any help appreciated.

答案1

得分: 2

右键单击父/根项目,然后选择 配置 > 配置并检测嵌套项目...

英文:

Right-click the parent/root project and choose Configure > Configure and Detect Nested Projects...

huangapple
  • 本文由 发表于 2020年10月23日 19:35:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/64499241.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定