我使用 java 在社区项目中设置了简单的多模型,但没有一个模块被识别或编译,我不知道为什么在 Windows 10 上使用:
IntelliJ IDEA 2022.3.2 (Community Edition)
Build #IC-223.8617.56, built on January 26, 2023
Runtime version: 17.0.5+1-b653.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Non-Bundled Plugins:
Batch Scripts Support (1.0.13)
CMD Support (1.0.5)
org.rust.lang (0.4.194.5382-223)
sandipchitale.springinitializr (1.0.17)
Docker (223.8617.59)
dev.flikas.idea.spring.boot.assistant.plugin (222.17.3)
Kotlin:223-1.8.0-release-345-IJ8617.56
Stock-ui pom
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.stockui</groupId>
<artifactId>stock-ui</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>stockcui</name>
<description>ui project for Spring Boot</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</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>
</project>
股票客户端 pom:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.stockclient</groupId>
<artifactId>stockclient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>stockclient</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</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>
</project>
如果我从命令行构建成功但没有创建类 X
XXXXX MINGW64 /c/dev/my/java/spring_applications/ReactiveSpringBootREST Service2/stockclient/stock-ui
$ mvn clean install -U
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.stockui:stock-ui >------------------------
[INFO] Building stockcui 1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.3.2:clean (default-clean) @ stock-ui ---
[INFO]
[INFO] --- spring-boot-maven-plugin:3.2.2:repackage (repackage) @ stock-ui ---
[INFO]
[INFO] --- maven-install-plugin:3.1.1:install (default-install) @ stock-ui ---
[INFO] Installing C:\dev\my\java\spring_applications\ReactiveSpringBootREST Service2\stockclient\stock-ui\pom.xml to C:\Users\xxxxx\.m2\com\stockui\stock-ui\1.0-SNAPSHOT\stock-ui-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.144 s
[INFO] Finished at: 2024-02-04T12:48:52+02:00
[INFO] ------------------------------------------------------------------------
这是stock-ui中唯一的类
package com.stockui.stockui;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class StockUIapplication {
public static void main(String[] args){
SpringApplication.run(StockUIapplication.class, args);
}
}
多模块项目通常使用根 pom 进行设置。
看一下这个例子:
根 pom 将声明如下:
添加模块可以通过以下方式完成:
访问项目结构以查看您的模块:
编译所有模块: