我有一个名为“Organizer”的Sping Boot 项目,包含5个模块:
- 应用
- 后端
- 客户端API
- 核心
- discord-bot
核心是所有其他模块中的依赖项。并且所有模块都是“应用程序”模块中的依赖项
每当我想在组织者上运行mvn clean install
时,都会构建所有内容,直到它到达“discord-bot”模块,在那里它失败了,说package net.dragoncoding.organizer.core does not exist
,同时IDE显示没有任何错误。
当我在所有模块上手动使用mvn clean install
时,我可以构建所有模块并构建项目。
我是不是漏掉了什么?
IntelliJ版本:IntelliJ IDEA 2023.1.3(Ultimate Edition)Build #IU-231.9161.38,构建于2023年6月20日
**编辑:**项目pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>net.dragoncoding</groupId>
<artifactId>Organizer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Organizer</name>
<description>Organizer</description>
<modules>
<module>application</module>
<module>client-api</module>
<module>backend</module>
<module>discord-bot</module>
<module>core</module>
</modules>
<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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.42.0.0</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-community-dialects</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>net.dragoncoding.organizer.app.Application</mainClass>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
下面是核心模块的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>
<parent>
<groupId>net.dragoncoding</groupId>
<artifactId>Organizer</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>core</artifactId>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
这里是pom.mldiscord-bot
模块的www.example.com:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.dragoncoding</groupId>
<artifactId>Organizer</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>discord-bot</artifactId>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.dragoncoding</groupId>
<artifactId>core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.dragoncoding</groupId>
<artifactId>client-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.11</version>
<exclusions>
<exclusion>
<groupId>club.minnced</groupId>
<artifactId>opus-java</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
2条答案
按热度按时间xxslljrj1#
将整个
<build>
节点从根Organizer
模块的POM文件移动到application
子模块的POM文件。通过在根POM中定义spring-boot-maven-plugin:repackage,每个子模块都会继承它。所以
core
子模块忠实地执行这个重新打包的目标,并将JAR中的类重新排列为要从命令行启动的对象。这就是为什么编译器在net.dragoncoding.organizer.core
中找不到任何东西的原因。您真正需要的只是重新打包application
子模块,以便可以从命令行运行它。通过执行
jar tf ~/.m2/repository/net/dragoncoding/core/0.0.1-SNAPSHOT/core-0.0.1-SNAPSHOT.jar
检查core
jar文件在此更改前后的内容。请注意,org/dragoncoding
类现在位于根目录,而不是BOOT-INF/classes
下。HTH。
nle07wnf2#
现在您已经手动完成了
mvn clean install
,右键单击IntelliJ IDEA中的根项目,并选择Maven => Reload project。那就再试一次有时IntelliJ在这些情况下只需要轻轻推动一下。