- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我之前已经在这里看到过这个问题,并且我已经查看了解决方案,但是我无法解决我遇到的问题。我在 Eclipse for Java 中创建了一个非常简单的 Maven 项目,我想运行输出 jar 文件,例如java -jar jar文件名.jar
我可以通过右键单击 Eclipse 中的项目并指示作为 Java 应用程序运行来运行该程序。我可以使用 mvn package 将项目构建为 jar 文件。运行 jar 文件,我得到了 joda 时间 NoClassDefFoundError 的输出。 joda jar 文件位于配置的存储库中,例如.m2/存储库/joda-time/joda-time/2.8.2。 Eclipse 中的项目没有指示任何错误。我正在使用 jdk1.8.0_92 Maven 版本 3.3.9 和 eclipse Java EE Neon 版本 4.6.0。 Java home 在环境变量中配置,类路径也配置为: ...\Java\jdk1.8.0_92\jre\lib;C:\Users\username.m2\repository
一些附加信息,类路径是正确的,没有拼写错误。我还查看了另一个类似问题的解决方案,其中建议是将外部 jar 添加到运行配置下的引导条目中。我还在 joda time 的 Java 构建路径中创建了一个条目,它正确地指向 .m2/repository.../joda-time/2.8.2 这看起来是当它从 eclipse 运行时,到 joda time jar 文件的路径是已知的(由于缺乏更好的术语)。然而,当构建 jar 文件时,该路径是未知的。我打开 jar 文件并查看 MANIFEST.MF 文件,我看到:
Manifest-Version: 1.0
Built-By: John
Class-Path: joda-time-2.8.jar
Build-Jdk: 1.8.0_92
Created-By: Maven Integration for Eclipse
Main-Class: hello.HelloMain
来源很简单: 包你好;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
public class HelloMain {
public static void main(String[] args) {
System.out.println("Hello From My Main ! It worked\n");
final DateTime today = new DateTime().withZone(DateTimeZone.UTC);
DateTime tommorrow = today.plusDays(3);
String startTime = today.toString(DateTimeFormat.forPattern("yyyy-MM- dd'T'HH:mm'Z"));
String endTime = tommorrow.toString(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm'Z"));
System.out.printf("The start time %s End Time %s \n", startTime, endTime);
}
}
这是我的 pom 文件:
<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>hello</groupId>
<artifactId>hello</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>hello.HelloMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8</version>
</dependency>
最佳答案
在尝试了多种不同的 Pom 文件方法之后,我决定采用一种不同的方法。这仅适用于您使用 Eclipse 执行此操作的情况,因为 Eclipse 提供导出到可运行 jar 功能。在 Eclipse 中突出显示您感兴趣的项目时,右键单击“Export”并选择“Java/Runnable JAR file”。单击下一步并选择“将所需的库打包到生成的 JAR 中”。这构建了包含我需要的所有必需 jar 文件的 jar 文件。虽然从使用 Maven 打包创建输出 jar 的角度来看,这确实不能解决问题,但它确实提供了正确的可执行 jar 文件。
关于java - java.lang.NoClassDefFoundError : org/joda/time/DateTime not working 的类似解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38231804/
我想避免创建 std::thread 的开销,因此我要实现一个线程池。我正在为一个设计决策而苦苦挣扎: 工作队列中的工作是否应该能够将工作添加到工作队列中?如果是,如何? 问题出现了,因为我想让我添加
color 属性正常工作,但其他两个属性(font-size 和 text-shadow)不起作用。当链接被访问时,它的字体大小应该减小到 20 px 并且应用 text-shadow 属性,但它没有
我已经安装并配置了 supervisor。 ps -ax 显示 10 个进程,例如:php/home/vagrant/Sites/mysite/artisan queue:work --tries=1
我对 php artisan queue::work 命令感到不安。 我的命令不起作用,但我的作业已插入作业表但从未执行。 我正在为队列使用 mongodb 驱动程序。 我做错了什么,请给我建议。 最
为什么我可以找到很多关于“工作窃取”的信息而没有关于“工作耸肩”作为动态负载平衡策略的信息? 通过“工作耸肩”,我的意思是将多余的工作从繁忙的处理器转移到负载较低的邻居上,而不是让空闲的处理器从忙碌的
首先,我正在为 MySQL 使用 DATE_ADD 函数。当试图在 php 中使用 $sqlA 时,由于某种原因它说语法错误(主要是 WHERE 之后的区域)。为什么? $sqlA = "SELECT
a:hover { color: #237ca8 !important; font-weight: bold; } a:active { color: #cccccc !imp
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 7 年前。 Improve this q
我试图让只能使用 Tab 键的用户可以访问我的网站。我遇到的问题是,当我尝试使用 tab 键选择 float 的 div 时,不会触发 :focus in css;我不知道为什么它没有被触发。鼠标悬停
我在尝试将 2 个 div 并排放置时遇到了问题。 display: inline 它会删除我的边框并且不会将两个 div 放在同一行上。 请指教: .gig { outline: 1px s
这是 fiddle :http://jsfiddle.net/j9Gmx/ 我怎样才能得到最小高度:100%;上类? 最佳答案 它正在 工作,但由于 div 的父级(正文)没有高度,100% 基本上是
我正在使用 Flutter WebRTC 来创建 P2P 视频通话。 我遇到了一个与网络相关的问题:我已经完成了应用程序,但它只适用于移动数据。 将网络更改为WiFi时,它不起作用并且连接状态挂起Ch
我是 JavaScript 和 jQuery 的初学者。我的 css 和 JavaScript 代码位于 html 文件外部。这个问题已经有了答案,我尝试了所有代码,但滚动不起作用。我不知道我错过了什
我正在使用 Sprin AMQP 的rabbittemplate 通过 RabbitMQ 发送和接收消息。我能够发送和接收消息,但是,我想优先处理消息。 例如,如果我推送 1000 条消息,假设奇数消
我已经在 WorkManager 中加入了一个PeriodicWork,并希望每次完成时都获取它的 Worker 的输出数据,但以下代码似乎不起作用,因为 Log 消息没有出现在 Logcat 中:
我有一个名为 areaOne 的 AngularJS 指令。当我使用 template 时,会显示模板,但当我在 area1.js 中使用 templateUrl 时,不会呈现模板 HTML。 我在这
“:after”选择器在应用于带有 FF 和 IE 的输入时不起作用 input:after { content: "title"; } 而它正在处理 p、a 等。 这是一个错
下面是适用于 oracle 但不适用于 PostgreSQL 的 Sql 查询。 select count(*) from users where id>1 order by username; 我知
position?:fixed 在 chrome 浏览器上不工作,但在 firefox 中工作正常。 我有一个侧边栏可以停止滚动并固定在顶部。它在 firefox 中运行完美,但在 chrome 中,
我有一段代码无法在 Firefox 中运行。当按钮悬停时,.icon 图像不会改变。它在 Chrome 中完美运行。 button.add-to-cart-button .button-left .i
我是一名优秀的程序员,十分优秀!