gpt4 book ai didi

java - 为什么 IntelliJ 给我包的名称和括号中的另一个包的名称?

转载 作者:行者123 更新时间:2023-12-05 03:37:49 24 4
gpt4 key购买 nike

(旁注:GameLogic 模块未在任何地方导入,可以忽略。)

正如您在下面的图片中看到的,'ConsoleApp' 的 java 文件旁边标有'[DesktopApp]',但 DesktopApp 模块没有。 ConsoleApp 和 DesktopApp 模块的 pom.xml 没有相互引用,那么 IntelliJ 怎么会这样标记源文件夹呢?

enter image description here

ConsoleApp/pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>TicTacToe</artifactId>
<groupId>com.example</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>ConsoleApp</artifactId>

<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>

</project>

DesktopApp/pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>TicTacToe</artifactId>
<groupId>com.example</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>DesktopApp</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>

</project>

pom.xml(父级pom.xml):

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>TicTacToe</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>GameLogic</module>
<module>DesktopApp</module>
<module>ConsoleApp</module>
</modules>

<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>

</project>

欢迎随时询问更多信息!

最佳答案

这可能是因为您将 Java 文件夹标记为模块文件夹而不是源文件夹。转到项目结构设置并删除以 Java 文件夹命名的模块。然后转到模块控制台应用程序并将 Java 文件夹标记为源。

关于java - 为什么 IntelliJ 给我包的名称和括号中的另一个包的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69166402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com