如何摆脱 Plexus Classworlds?

发布于 2025-01-10 02:57:22 字数 5383 浏览 0 评论 0原文

我有 2 个不同的 JAVA 11 子项目基于相同的父级 maven pom.xml。

第一个是从一开始就使用 Maven 的 Spring 初始化程序 设置的,第二个是最初设置的,没有SpringBoot。

第二个让我头疼,因为它缺少一些依赖项(JAI、JPEG2000),这些依赖项位于父 pom.xml 中,并且很好地包含在使用 Spring maven 插件打包应用程序的第一个项目中,但没有包含在第二个项目中。

这就是为什么我决定将第二个项目迁移到SpringBoot。但它仍然缺少与以前相同的依赖项,当我打印加载的类时,它仍然显示: /home/path/to/netbeans/java/maven/boot/plexus-classworlds-2.6.0.jar (我使用的是 Netbeans 12),而第一个项目按照预期列出了所有已加载的 jar。第二个项目 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>My.Package</groupId>
   <artifactId>PyProg</artifactId>
   <version>1.0.0</version>
   <packaging>jar</packaging>
   <name>My prog Name</name>
   <description>SpringBoot version of My Prog</description>
   <parent>
      <artifactId>MySuperParent</artifactId>
      <groupId>My.Package</groupId>
      <version>1.0-SNAPSHOT</version>
   </parent>
   <!--Uses a different parent than Spring Boot one see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-maven-without-a-parent-->
   <dependencyManagement>
      <dependencies>
         <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.16.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
         </dependency>
      </dependencies>
   </dependencyManagement>
   <dependencies>
      <dependency>
         <groupId>My.Package</groupId>
         <artifactId>Base</artifactId>
         <version>1.0-SNAPSHOT</version>
      </dependency>
      <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.openjfx</groupId>
         <artifactId>javafx-fxml</artifactId>
         <version>11.0.2</version>
         <type>jar</type>
      </dependency>
      <dependency>
         <groupId>org.openjfx</groupId>
         <artifactId>javafx-controls</artifactId>
         <version>11.0.2</version>
         <type>jar</type>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <scope>test</scope>
         <version>${junitVersion}</version>
         <type>jar</type>
      </dependency>
      <dependency>
         <groupId>org.openjfx</groupId>
         <artifactId>javafx-maven-plugin</artifactId>
         <version>0.0.2</version>
         <type>maven-plugin</type>
      </dependency>
   </dependencies>
   <build>
      <resources>
         <resource>
            <!--Resource folder that should be included-->
            <directory>src/main/resources</directory>
            <!--Resources that should not-->
            <excludes>
               <exclude>solo/**</exclude>
               <exclude>forYourEyesOnly/**</exclude>
            </excludes>
         </resource>
      </resources>
      <plugins>
         <!-- Package as an executable jar -->
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.16.RELEASE</version>
            <executions>
               <execution>
                  <goals>
                     <goal>repackage</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</project>

Plexus-classworlds 不在任何 pom 中,现在我将第二个项目移至 SpringBoot,两个项目 pom 看起来都很相似,那么如何禁用 plexus-classworlds 并摆脱它,以便在执行 时System.out.println(System.getProperty("java.class.path").replace(":","\n")); 从类路径获取加载的类,我看到一个列表没有这个单一的丛级世界罐子?

我相信我可能在过去的某个时候弄乱了一些启用这个丛类世界的配置文件,但我不记得了。

我尝试从 Netbeans 中删除这个 jar,但没有一个项目启动。

那么有人可以告诉我如何摆脱类路径中显示的 plexus-classworlds.jar 吗?

任何提示表示赞赏!

I have 2 different JAVA 11 child projects based on the same parent maven pom.xml.

The first one was set up with Spring initializer for Maven from the beginning and the second one was set up initially without SpringBoot.

The second one was giving me headaches because it was missing some dependencies (JAI, JPEG2000) which were in the parent pom.xml and well included in the first project which used Spring maven plugin to package the app, but not in the second one.

That's why I decided to move the second project to SpringBoot. But it still misses the same dependencies as previously and when I print the loaded classes it still shows : /home/path/to/netbeans/java/maven/boot/plexus-classworlds-2.6.0.jar (I am using Netbeans 12) whereas the first project lists all loaded jars as it is expected to do. This second project pom.xml reads as follows :




<?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>My.Package</groupId>
   <artifactId>PyProg</artifactId>
   <version>1.0.0</version>
   <packaging>jar</packaging>
   <name>My prog Name</name>
   <description>SpringBoot version of My Prog</description>
   <parent>
      <artifactId>MySuperParent</artifactId>
      <groupId>My.Package</groupId>
      <version>1.0-SNAPSHOT</version>
   </parent>
   <!--Uses a different parent than Spring Boot one see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-maven-without-a-parent-->
   <dependencyManagement>
      <dependencies>
         <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.16.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
         </dependency>
      </dependencies>
   </dependencyManagement>
   <dependencies>
      <dependency>
         <groupId>My.Package</groupId>
         <artifactId>Base</artifactId>
         <version>1.0-SNAPSHOT</version>
      </dependency>
      <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.openjfx</groupId>
         <artifactId>javafx-fxml</artifactId>
         <version>11.0.2</version>
         <type>jar</type>
      </dependency>
      <dependency>
         <groupId>org.openjfx</groupId>
         <artifactId>javafx-controls</artifactId>
         <version>11.0.2</version>
         <type>jar</type>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <scope>test</scope>
         <version>${junitVersion}</version>
         <type>jar</type>
      </dependency>
      <dependency>
         <groupId>org.openjfx</groupId>
         <artifactId>javafx-maven-plugin</artifactId>
         <version>0.0.2</version>
         <type>maven-plugin</type>
      </dependency>
   </dependencies>
   <build>
      <resources>
         <resource>
            <!--Resource folder that should be included-->
            <directory>src/main/resources</directory>
            <!--Resources that should not-->
            <excludes>
               <exclude>solo/**</exclude>
               <exclude>forYourEyesOnly/**</exclude>
            </excludes>
         </resource>
      </resources>
      <plugins>
         <!-- Package as an executable jar -->
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.16.RELEASE</version>
            <executions>
               <execution>
                  <goals>
                     <goal>repackage</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</project>

Plexus-classworlds is not in any pom, both projects pom look alike now that I moved the second one to SpringBoot, so how can I disable plexus-classworlds and get rid of it, so that when doing System.out.println(System.getProperty("java.class.path").replace(":","\n")); to get the loaded classes from class path, I see a list not this single plexus-classworlds jar ?

I believe I may have messed up with some config file sometime in the past that enabled this plexus-classworlds, but I can't remember.

I tried to remove this jars from Netbeans but then none of the projects boots up.

So could somebody tell me how to get rid of plexus-classworlds.jar shown in the classpath ?

Any hint appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文