如何解决为什么 maven 模块无法识别 Java 和 Spring?
我在 java/maven 中的模块化有一个很大的问题,我只想有 2 个可以相互交互的模块,web - web 层,端点,rest 等,存储 - 连接到 mongodb,来自 web 层的请求。我用 maven 创建了一个新项目,通过选择 Spring Initializer 等向其中添加模块。现在我无法运行它们,intelliJ 无法识别文件、注释等。当我尝试设置运行配置时,有如下内容:>
另外,正如你在下面看到的,java 包不再是 java 的了:
是的,我知道您会怎么想 - 更改项目结构并选择源文件夹,不,这也不起作用:
当我添加这些模块时,它们的 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>org.example</groupId>
<artifactId>MediaHosting</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<modules>
<module>storage</module>
<module>web</module>
</modules>
</project>
还有一个子 pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>mr.fisherman</groupId>
<artifactId>web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>web</name>
<description>Web layer of application</description>
<properties>
<java.version>11</java.version>
</properties>
dependencies
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
谁能告诉我我做错了什么?或者也许有解决方案可以轻松创建此结构:
父文件夹: 网络 主要的 测试 贮存 主要的 测试 它让网络和存储相互交互,比如我什么时候应该在 IntelliJ 中正常运行它们而不是通过 Maven 插件?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。