Closed LikeKey1 closed 3 years ago
Можете поделится примером JSON, который вы получаете?
Чтоб получить JSON нужно:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
</dependency>
DEBUG
в методе main
:
public static void main(String[] args) {
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
new BotsLongPoll(new MyBot()).run();
}
Этот JSON должен содержать поле "type": "message_new"
Пример такого JSON: https://github.com/yvasyliev/java-vk-bots-long-poll-api/blob/master/src/test/resource/json/response/message_new/message_new_photo_sample_5_110.json
Теперь к началу предыдущей ошибки добавилось это:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/aleha/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.11.2/log4j-slf4j-impl-2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/aleha/.m2/repository/org/slf4j/slf4j-simple/1.7.30/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] 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
Похоже, что у вас в проекте уже подключена log4j 2 имплементация.
В таком случае:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
</dependency>
resource
файл log4j2.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
public static void main(String[] args) {
new BotsLongPoll(new MyBot()).run();
}
Пожалуйста, сообщите, если у вас снова воспроизведётся эта ошибка.
Дайте знать, если это ещё актуально.
Ошибка:
Как выглядят классы: ` public class MyBot extends LongPollBot {
} `
` public class Application {
} `