Answer the question
In order to leave comments, you need to log in
Why does this error appear?
Did telegram bota'a according to the documentation ( https://github.com/rubenlagus/TelegramBots/wiki/Ge... )
Errors pop up:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject .internal.cglib.core.$ReflectUtils$1 (file:/C:/Users/Vladp/.m2/repository/com/google/inject/guice/4.2.2/guice-4.2.2.jar) to method java. lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils $1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Here is the java and xml code:
import org.telegram.telegrambots.ApiContextInitializer;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
public class Bot extends TelegramLongPollingBot {
public static void main (String[] args) {
ApiContextInitializer.init();
TelegramBotsApi botsApi = new TelegramBotsApi();
try {
botsApi.registerBot(new Bot());
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
@Override
public void onUpdateReceived(Update update) {
if (update.hasMessage() && update.getMessage().hasText()) {
SendMessage message = new SendMessage() // Create a SendMessage object with mandatory fields
.setChatId(update.getMessage().getChatId())
.setText(update.getMessage().getText());
try {
execute(message); // Call method to send the message
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
}
@Override
public String getBotUsername() {
return "BotTotCampot_bot";
}
@Override
public String getBotToken() {
return "Тут мой токен";
}
}
<?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>org.example</groupId>
<artifactId>telebot</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.9.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.13</version>
</dependency>
</dependencies>
</project>
Answer the question
In order to leave comments, you need to log in
These are not errors, but warnings. They will not affect the operation of your program in any way.
In case you're wondering what the warnings are about, in short - the library you're using uses another library under the hood - Guice. This Guice is accessing the JDK internal API, the JDK issues a warning in response to such an invasion of its personal boundaries.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question