Bob*_*bby 2 java spring-boot telegram-bot
我尝试从这里https://github.com/rubenlagus/TelegramBots创建一个机器人
它作为一个简单的应用程序工作,但是当我尝试添加Spring Boot时,它不起作用。我想这是因为Spring Boot启动了Tomcat,而电报Bot尝试发送/接收一些http。
我没有任何错误(机器人以@Component bean启动)。
甚至可以将这种机器人与Spring Boot应用程序或至少一个Web应用程序连接起来吗?
小智 5
您可以尝试telegrambots-spring-boot-starter从同一库使用。
您的主要配置应如下所示:
@SpringBootApplication
public class YourApplicationMainClass {
public static void main(String[] args) {
ApiContextInitializer.init();
SpringApplication.run(YourApplicationMainClass.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
和您的机器人课程:
// Standard Spring component annotation
@Component
public class YourBotName extends TelegramLongPollingBot {
//Bot body.
}
Run Code Online (Sandbox Code Playgroud)
您可以在这里找到更多信息https://github.com/rubenlagus/TelegramBots/tree/master/telegrambots-spring-boot-starter
| 归档时间: |
|
| 查看次数: |
2225 次 |
| 最近记录: |