java -jar C:\Users\Alexander\Projects/Simulator/target/simulator-1.0-SNAPSHOT.jar 1 "2018-01-01 00:00:00"
但这将导致以下错误:
Error: Unable to initialize main class com.simulator.drivers.MainDriver
Caused by: java.lang.NoClassDefFoundError: org/jooq/TableLike
下面是我现在拥有的pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.simulator</groupId>
<artifactId>simulator</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.6.0</junit.version>
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
<maven-checkstyle-plugin.version>3.1.0</maven-checkstyle-plugin.version>
<checkstyle.version>8.29</checkstyle.version>
<checkstyle-rules.version>4.0.1</checkstyle-rules.version>
<maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
<maven-javadoc-plugin.version>3.0.0</maven-javadoc-plugin.version>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
<!-- JaCoCo thresholds. Increase gradually as you add tests. -->
<jacoco.unit-tests.limit.instruction-ratio>0%</jacoco.unit-tests.limit.instruction-ratio>
<jacoco.unit-tests.limit.branch-ratio>0%</jacoco.unit-tests.limit.branch-ratio>
<jacoco.unit-tests.limit.class-complexity>20</jacoco.unit-tests.limit.class-complexity>
<jacoco.unit-tests.limit.method-complexity>5</jacoco.unit-tests.limit.method-complexity>
<java.version>1.8</java.version>
<maven.compiler.version>3.8.1</maven.compiler.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.14.9</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-jackson</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<!--<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>-->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.simulator.drivers.MainDriver</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<release>15</release>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.simulator.drivers.MainDriver</mainClass>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
</plugin>
</plugins>
</reporting>
<profiles>
<!-- Publish coverage report to Coveralls, only when running in Travis. -->
<profile>
<id>travis</id>
<activation>
<property>
<name>env.TRAVIS</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${coveralls-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
我已经纠结了几天了,我不明白为什么会这样。看起来JOOQ依赖项没有与jar合并,所以我找到了这个插件,但这也没有起到作用。有人能帮我解决这个问题吗?
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.8.1
Built-By: Alexander
Build-Jdk: 15.0.2
Class-Path: gson-2.3.1.jar json-simple-1.1.jar jackson-databind-2.12.1.j
ar jackson-annotations-2.12.1.jar jackson-core-2.12.1.jar mysql-connect
or-java-8.0.23.jar protobuf-java-3.11.4.jar commons-math3-3.6.1.jar com
mons-codec-1.10.jar commons-lang3-3.6.jar jooq-3.14.9.jar reactive-stre
ams-1.0.2.jar jaxb-api-2.3.1.jar javax.activation-api-1.2.0.jar convert
er-jackson-2.9.0.jar commons-io-2.8.0.jar retrofit-2.9.0.jar okhttp-3.1
4.9.jar okio-1.17.2.jar httpclient-4.5.13.jar httpcore-4.4.13.jar commo
ns-logging-1.2.jar
Main-Class: com.simulator.drivers.MainDriver
JAR不包含外部依赖项。
我建议您通过以下方式将依赖项与jar捆绑在一起:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libs</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>runtime</includeScope>
<excludeScope>test</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
插件会为您将libs
文件夹添加到类路径中。
我在从命令行运行一个java程序时遇到了严重的麻烦。我觉得我已经接近弄清楚哪里出了问题,但我只是不知所措,我需要帮助。 我正在尝试用以下命令运行一个简单的Hello World程序(在windows上的VSCode中,使用bash terminal): 这根本不起作用,但是,写入文件的完整路径确实起作用,所以像这样的东西是起作用的。 此外,使用F5运行文件也可以正常工作。我希望用命令行参数运行我的
我知道甚至这个问题已经被提出了几次,但没有找到解决这个问题的方法。我使用的编译命令:。我使用的运行命令: 错误:
和build.gradle文件(project)中的这一行: 所以..知道发生了什么吗?我知道有重复的文件,但他们是自动创建的!!有工作人员吗?
我最近--就像今天一样--对学习用Clojure编程产生了兴趣。现在,在安装了最新版本的Java jdk并下载了leiningen脚本之后,我遵循了后者的安装说明,特别是在http://www.lispcast.com/clojure-ubuntu上提供的说明。 现在,在运行并下载相关的jar文件之后,程序退出时会出现一个关于找不到类的错误。该错误如下: 线程“main”java.lang.Exc
问题内容: 我正在学习Java中的GUI,为此我创建了一个演示程序: 它已成功编译。但是,当我尝试执行程序时,发现以下错误: 我正在使用Xubuntu 10.10并给出: 我该怎么办? 还有一件事:这是我尝试执行Dr. Java和HJSplit的jar文件时遇到的错误。 问题答案: Ubuntu可以选择安装无头Java,这意味着无需图形库。并非总是如此,但是前几天我在尝试运行Java文本编辑器10
问题内容: 这是简单的go应用程序。如果运行以下代码,则会出现“运行:无法运行非主程序包”错误。 要解决此问题,我只需要将该包命名为即可。但是我不明白为什么我需要这样做。我应该能够随心所欲地命名包裹。 另一个问题,我知道主要功能是程序的入口点,您需要它。否则它将无法正常工作。但是我看到一些没有主要功能的代码仍然可以使用。 单击此链接,页面底部的示例未使用包main和main函数,它仍然有效。只是好