• 多模块项目Module must not contain source root. The root already belongs to module


    多模块项目Module “*” must not contain source root *. The root already belongs to module “*”.

    有时候新建了maven工程,然后删了里面的src目录让它成为空的父项目,但是会报下面的错误。

    Module “*” must not contain source root *. The root already belongs to module “*”.

    打开工程的iml文件后,发现里面记录了开始的源文件和资源文件的配置。

    <?xml version="1.0" encoding="UTF-8"?>
    <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
      <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
        <output url="file://$MODULE_DIR$/target/classes" />
        <output-test url="file://$MODULE_DIR$/target/test-classes" />
        <content url="file://$MODULE_DIR$">
          <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
          <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
          <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
          <excludeFolder url="file://$MODULE_DIR$/target" />
        </content>
        <orderEntry type="inheritedJdk" />
        <orderEntry type="sourceFolder" forTests="false" />
      </component>
    </module>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    修改以后的

    <?xml version="1.0" encoding="UTF-8"?>
    <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
      <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
        <output url="file://$MODULE_DIR$/target/classes" />
        <output-test url="file://$MODULE_DIR$/target/test-classes" />
        <content url="file://$MODULE_DIR$">
          <excludeFolder url="file://$MODULE_DIR$/target" />
        </content>
        <orderEntry type="inheritedJdk" />
        <orderEntry type="sourceFolder" forTests="false" />
      </component>
    </module>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    网上的另一种解决方式:
    这里写图片描述
    在项目设置中, 右侧有源文件、资源文件等 目录列表

    删除不是子工程该有的目录。

  • 相关阅读:
    其他
    聚类算法:ISODATA算法
    大神博客
    Fiddldr 教程之:HTTP协议详解(转)
    设计模式之装饰模式的复习
    NOIP 2011 聪明的质监员
    CSP-S2020/NOIP2020模板总结(Updating)
    CSP-S2020/NOIP2020复习指南
    洛谷 U137412 高斯的小宇宙
    NOIP2020模板测试题大全
  • 原文地址:https://www.cnblogs.com/jpfss/p/10785092.html
Copyright © 2020-2023  润新知