Хост телеграм бота Java на хероку.Maven
Всем привет.Я пересмотрел уже все статьи с различными вариациями и вариантами,пробовал и через гит,и через плагин Хероку от Мавен , и через гит Хаб . Результат каждый раз один и тот же.Прошу вас,помогите,я хнаю что что то банальное.но не могу уже.Вот вывод лога хероку
2021-01-24T09:07:03.296977+00:00 app[api]: Deploy d4b69b22 by user [email protected]
2021-01-24T09:07:03.296977+00:00 app[api]: Release v12 created by user [email protected]
2021-01-24T09:07:05.000000+00:00 app[api]: Build succeeded
2021-01-24T09:07:05.138216+00:00 heroku[worker.1]: State changed from crashed to starting
2021-01-24T09:07:08.672597+00:00 heroku[worker.1]: Starting process with command `sh target/bin/workerBot`
2021-01-24T09:07:09.303485+00:00 heroku[worker.1]: State changed from starting to up
2021-01-24T09:07:10.498446+00:00 app[worker.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-01-24T09:07:10.616114+00:00 app[worker.1]: Error: Could not find or load main class src.main.java.bot.SBKbot
2021-01-24T09:07:10.658872+00:00 heroku[worker.1]: Process exited with status 1
2021-01-24T09:07:10.694882+00:00 heroku[worker.1]: State changed from up to crashed
начинаю впадать в отчаяние , ибо проблема в чём то банальном . Не видит мейн в упор ,и просит подобрать какие то параметры. Поясните толком что я сделал,или не доделал.Собираю при помощи Maven.Я пробовал действительно около 5-и десятков разных вариантов,И уже 5-ый день не могу его захостить . Дэплой происходит успешко,но бот не отвечает. Ссылка на гитХаб
https://github.com/memento211/sslobodskoybot.git
Содержимое procfile : worker: sh target/bin/workerBot
Содержимое pom.xml
<?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>bot</groupId>
<artifactId>SBKbot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SBKbot</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>3.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<assembleDirectory>target</assembleDirectory>
<programs>
<program>
<mainClass>src.main.java.bot.SBKbot</mainClass>
<name>workerBot</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.3</version>
</plugin>
</plugins>
</build>
</project>
содержимое класса Bot.java
public class Bot extends TelegramLongPollingBot{
@Override
public void onUpdateReceived(Update update) {
String message = update.getMessage().getText();
switch(message) {
case("демики"):
sendMsgDemiki(update.getMessage().getChatId().toString(), message);
break;
case("Демики"):
sendMsgDemiki(update.getMessage().getChatId().toString(), message);
break;
case("24г"):
sendMsgDemiki(update.getMessage().getChatId().toString(), message);
break;
case("владики"):
sendMsgVladiki(update.getMessage().getChatId().toString(), message);
break;
case("Владики"):
sendMsgVladiki(update.getMessage().getChatId().toString(), message);
break;
case("Inf"):
sendMsgInf(update.getMessage().getChatId().toString(), message);
break;
case("inf"):
sendMsgInf(update.getMessage().getChatId().toString(), message);
break;
}
}
public synchronized void sendMsgDemiki(String chatId, String s) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(chatId);
sendMessage.setText("24г,приём... @Plumpla @NastasiaMolotkova");
try {
sendMessage(sendMessage);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
public synchronized void sendMsgVladiki(String chatId, String s) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(chatId);
sendMessage.setText("AGHTUNGH @ZhekaRoyzman @TolyaOdessit");
try {
sendMessage(sendMessage);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
public synchronized void sendMsgInf(String chatId, String s) {
InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup();
InlineKeyboardButton inlineKeyboardButton1 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton2 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton3 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton4 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton5 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton6 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton7 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton8 = new InlineKeyboardButton();
InlineKeyboardButton inlineKeyboardButton9 = new InlineKeyboardButton();
inlineKeyboardButton1.setText("Игра дня");
inlineKeyboardButton1.setCallbackData("1");
inlineKeyboardButton2.setText("Игра недели");
inlineKeyboardButton2.setCallbackData("2");
inlineKeyboardButton3.setText("Игра месяца");
inlineKeyboardButton3.setCallbackData("3");
inlineKeyboardButton4.setText("Слив дня");
inlineKeyboardButton4.setCallbackData("4");
inlineKeyboardButton5.setText("Слив недели");
inlineKeyboardButton5.setCallbackData("5");
inlineKeyboardButton6.setText("Слив месяца");
inlineKeyboardButton6.setCallbackData("6");
inlineKeyboardButton7.setText("ban");
inlineKeyboardButton7.setCallbackData("7");
inlineKeyboardButton8.setText("Razrab");
inlineKeyboardButton8.setCallbackData("8");
inlineKeyboardButton9.setText("MoreInf");
inlineKeyboardButton9.setCallbackData("9");
List<InlineKeyboardButton> keyboardButtonsRow1 = new ArrayList<>();
List<InlineKeyboardButton> keyboardButtonsRow2 = new ArrayList<>();
List<InlineKeyboardButton> keyboardButtonsRow3 = new ArrayList<>();
keyboardButtonsRow1.add(inlineKeyboardButton1);
keyboardButtonsRow1.add(inlineKeyboardButton2);
keyboardButtonsRow1.add(inlineKeyboardButton3);
keyboardButtonsRow2.add(inlineKeyboardButton4);
keyboardButtonsRow2.add(inlineKeyboardButton5);
keyboardButtonsRow2.add(inlineKeyboardButton6);
keyboardButtonsRow3.add(inlineKeyboardButton7);
keyboardButtonsRow3.add(inlineKeyboardButton8);
keyboardButtonsRow3.add(inlineKeyboardButton9);
List<List<InlineKeyboardButton>> rowList = new ArrayList<>();
rowList.add(keyboardButtonsRow1);
rowList.add(keyboardButtonsRow2);
rowList.add(keyboardButtonsRow3);
inlineKeyboardMarkup.setKeyboard(rowList);
SendMessage message = new SendMessage().setChatId(chatId).setText("qq").setReplyMarkup(inlineKeyboardMarkup);
message.enableMarkdown(true);
message.setChatId(chatId);
message.setText("SBK BOT INFO");
try {
sendMessage(message);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
@Override
public String getBotUsername() {
return "asdzxc_bot";
}
@Override
public String getBotToken() {
return "1326504042:AAGzsn0EMa6R8uVPUBo3xnBwpAhZELlrdGU";
}
}
ну и класс Main.java
public class Main {
public static void main(String[] args) {
ApiContextInitializer.init();
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
try {
telegramBotsApi.registerBot(new Bot());
} catch (TelegramApiRequestException e) {
e.printStackTrace();
}
}
}
Ответы (1 шт):
В pom файл поменяйте строку
<mainClass>src.main.java.bot.SBKbot</mainClass>
на
<mainClass>bot.SBKbot.Main</mainClass>
у вас package bot.SBKbot