- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 Intellij 在 IDE 中运行时出现以下错误 -
ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
当我运行 jar 文件时 -
trevor@trevor-Lenovo-YOGA-510-14AST:~/decent/Master5/out/artifacts/Master5_main_jar$ java -jar Master5.main.jar Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at BlockgetConnection.(BlockgetConnection.java:12) at BlockgetAccount.getAccountByName(BlockgetAccount.java:31) at BlockgetStart.main(BlockgetStart.java:8) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more
我没有明确记录,我假设在体面的逻辑中需要以某种方式记录。我包含了我的 build.gradle。我已经包含了一些日志记录的依赖项。对解决方案有什么想法吗?
代码(主类)-
import ch.decent.sdk.model.Account;
public class BlockgetStart {
public static void main(String[] args) {
BlockgetAccount anAccount = new BlockgetAccount();
Account myAcct = anAccount.getAccountByName("trevor3");
}
}
使用此类的实例 -
import ch.decent.sdk.DCoreApi;
import ch.decent.sdk.crypto.Address;
import ch.decent.sdk.crypto.Credentials;
import ch.decent.sdk.model.Account;
import ch.decent.sdk.model.AssetAmount;
import ch.decent.sdk.model.Fee;
import ch.decent.sdk.model.TransactionConfirmation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
@Component
public class BlockgetAccount {
// connection to accounts
private static final Long AMOUNT_OF_DCT_REQUIRED_FOR_CREATION = 100000L;
@Autowired
private BlockgetConnection connectionExample;
@Autowired
private BlockgetLogin loginExample;
@Autowired
private BlockgetGenerateKeys generateKeys;
/**
* Example of getting any account by its name.
*
* @param accountName name of the account e.g. dw-account
* @return Account instance for given account name
*/
public Account getAccountByName(String accountName) {
connectionExample = new BlockgetConnection();
final DCoreApi dcoreApi = connectionExample.connect();
return dcoreApi
.getAccountApi()
.getByName(accountName)
.blockingGet();
}
/**
* Example of account creation with initial fee.
*
* @param newAccountName Unique account name that you wish to create.
* @return Confirmation about transaction
*/
public TransactionConfirmation createAccount(String newAccountName) {
final DCoreApi dcoreApi = connectionExample.connect();
final Credentials credentials = loginExample.login();
final Address newAccountPublicKey = generateKeys.generateKeys();
final AssetAmount dctAssetAmount = new AssetAmount(AMOUNT_OF_DCT_REQUIRED_FOR_CREATION);
final Fee initialFee = new Fee(dctAssetAmount.getAssetId(), AMOUNT_OF_DCT_REQUIRED_FOR_CREATION);
return dcoreApi.getAccountApi().create(
credentials,
newAccountName,
newAccountPublicKey,
initialFee
).blockingGet();
}
}
构建.gradle-
plugins {
id 'java'
}
group 'com.blockget.Master5'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
jar { manifest { attributes 'Main-Class': 'BlockgetStart' } }
allprojects {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
// https://mvnrepository.com/artifact/org.springframework/spring-context
// https://mvnrepository.com/artifact/org.springframework/spring-context
compile group: 'org.springframework', name: 'spring-context', version: '5.1.8.RELEASE'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-ap
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.26'
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.12.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'com.github.DECENTfoundation:DCoreKt-SDK:2.3.1'
}
我得到这个是为了 jar 故障 -
trevor@trevor-Lenovo-YOGA-510 14AST:~/decent/Master5/out/artifacts/Master5_main_jar$ jar tf Master5.main.jar META-INF/MANIFEST.MF META-INF/ BlockgetNftMgr.class BlockgetLogin.class BlockgetConnection.class BlockgetNft.class BlockgetStart.class BlockgetAccount.class BlockgetGenerateKeys.class
记录器应该在这里吗?
最佳答案
如果将“资源”目录标记为“资源根”会有帮助吗?
在这种情况下,您需要将 log4j2.xml 文件放在 src 文件夹下,以便能够在类路径上找到它。将其放在 src/main/resources 或 src/test/resources 下。
其他解决方案:使用系统属性-Dlog4j.configurationFile=file:/path/to/file/log4j2.xml
关于java - 如何解决 - ERROR StatusLogger No Log4j 2 配置文件找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57219449/
我需要安装一个 VPN 配置文件,以后可以在没有用户干预的情况下进行更改。直接的方法是安装 VPN 配置文件,然后安装 MDM 配置文件,以便以后可以更改配置。 但是,我的要求仅与 VPN 配置有关,
配置文件 全局配置文件hibernate.cfg.xml hibernate.cfg.xml --> com.mysql.cj
我想知道有没有一种方法可以设置配置,我可以有两个数据库条目,当环境是本地时和在服务器上时都可以工作。 我很久以前就通过代码进行切换时遇到了一个解决方案。现在无法找到它。你们是怎么做到的? 最佳答案 我
通常我总能在 Stack Overflow 上找到我要找的东西。但是这次我真的难住了。 我已经阅读了针对遇到类似问题的人的其他 Stack Overflow 回复;但无济于事。 (我认为其中一部分原因
我是 Hadoop 新手。我正在尝试设置单节点集群。 我注意到在我读过的文档中(甚至在 Apache 的配置站点上)它总是引用 conf/目录中的配置文件。但是,当我下载 2.X.X 版时,我只能在
好吧,我之前发布了如何读取其他程序的其他配置文件(这里是链接 Previous Post 。我设法做到了。但是现在还有另一个问题。场景是这样的,我有两个程序。程序 A 从配置文件中读取其配置,程序 B
【全局(系统)配置文件】 复制代码 代码如下: /etc/crontab Linux 主要的配置文件都在 etc 目录下。 复制代码
Apache HBase配置文件 本节是本章内容的开篇,我们首先来认识Apache HBase中有哪些需要的配置文件! Apache HBase使用与Apache Hadoop相同的配置系统。所有
我想了解如何为我们的实验构建配置文件 让我们以 AllenNLP 文档中的这个例子为例 training and prediction 特别是这个片段 我们从哪里得到“token_embedders”
我正在研究 MAVEN 配置文件,我有一个关于使用变量设置属性的问题。目前,我正在使用以下配置: Action type D restriction actionTy
我知道以前可能有人问过这个问题,但我似乎无法为我找到正确的答案。 我有一个名为 的 Windows 服务foobar.exe .我有一个名为 的应用程序配置文件foobar.exe.confi
我使用 FitNesse 作为功能测试框架。当 FitNesse 运行需要配置的代码时,我遇到了麻烦。 如果我需要从配置文件中获取连接字符串,我可以通过将它添加到 FitServer.exe.conf
我对我的 Jenkins 输出感到有些困惑。 关于 Jenkins 的工作:(在底部缩短了 pom.xml) mvn deploy -Pprofile1 我所有的插件将运行 4 次: 父/pom.xm
我偶尔会遇到一个问题,即为设备配置开发版本的应用程序。错误消息通常是“找不到此可执行文件的有效配置文件”。 我已遵循所有 Apple 说明:我拥有有效的开发证书,开发人员配置文件包含相关设备的设备 I
我正在尝试在 F# 控制台应用程序中使用 NLog,我已设法使用 App.config 中的配置部分使其工作,但无法使用独立的 NLog.config 文件使其工作。我的 NLog.config 文件
有没有办法像在 rubocop 中一样使用配置文件禁用 puppet-lint 中的检查?配置文件应该是txt文件、json文件还是其他格式? 最佳答案 是的,该文件名为 .puppet-lint.r
我有多个网站,它们都具有相同的代码,但应用程序设置不同。我想将我的应用程序设置放在位于虚拟目录中的单独配置文件中。这将允许我在所有站点之间共享所有代码的单个副本,每个站点具有不同的虚拟目录。 不幸的是
我在 Ubuntu 上使用 ghci 6.8.2。 ghci 是否使用配置文件来进行一些初始设置?例如::设置提示符“ghci>”。 最佳答案 您是否尝试过将 :set Prompt "ghci> "
我继承了一个运行 JBoss 7.x 服务器、java 后端等单个实例的项目。我对 JBoss 完全陌生,我对文件结构的配置感到好奇),我必须拥有什么以及在哪里。 documentation其结构与我
我有一个关于 Android 的问题。我只需要在开始时运行其中一项 Activity 一次。因此,通常最好的解决方案是创建包含标志 isFirstRun 的文件并在应用程序启动后检查该值。 但在我的应
我是一名优秀的程序员,十分优秀!