我是编程新手,并且使用可以在Internet上找到的所有资源制作第一个程序。因此,我使用NetBeans 11.2在Maven Application中制作了Java。当我编译程序时,我终于说到了要点,但现在我陷入了困境。我试图从命令提示符下运行它,并且问题消失了。首先,我不得不处理NoClassDefFoundError: AbsoluteLayout
问题。我必须通过将整个项目中的布局更改为NullLayout
来解决此问题。程序最终启动后,我收到另一个错误NoClassDefFoundError: com/mchange/v2/c3p0/ComboPooledDataSource
。几天来,我一直在寻找答案,但仍然没有运气。尝试了所有建议的步骤。
由于某种原因,您似乎不想加载依赖项。
有人可以帮我吗?
谢谢。
<?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>ews.ykotov</groupId>
<artifactId>TechInfo</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>mchange-commons-java</artifactId>
<version>0.2.19</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.5</version>
</dependency>
<dependency>
<groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-all</artifactId>
<version>1.6.5-1</version>
</dependency>
<dependency>
<groupId>com.toedter</groupId>
<artifactId>jcalendar</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>AbsoluteLayout</artifactId>
<version>RELEASE112</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>techinfo1.MainPage</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:0)
感谢@Simon终于解决了该问题,并进入了下一阶段。我还必须使用本文(https://crunchify.com/how-to-create-build-java-project-including-all-dependencies-using-maven-maven-resources-maven-dependency-maven-jar-plugin-tutorial/)修改pom.xml的文件构建部分。也许有人会觉得有用。