简体   繁体   English

如何在Spring Boot中注册Alexa V2 Servlet

[英]How can I register Alexa V2 Servlet in Spring Boot

With Alexa, I want to call my Spring Boot application, which runs on a Google App Engine. 使用Alexa,我想调用运行在Google App Engine上的Spring Boot应用程序。 I can send requests from the Alexa-Simulator and can log the request. 我可以从Alexa-Simulator发送请求,并可以记录请求。

I followed this tutorial ( https://medium.freecodecamp.org/implementing-an-alexa-skill-with-spring-boot-also-why-would-you-do-such-a-thing-9992c0797646 ) to register the SpeechletServlet to call my Intents. 我按照本教程( https://medium.freecodecamp.org/implementing-an-alexa-skill-with-spring-boot-also-why-would-you-do-such-a-thing-9992c0797646 )注册了SpeechletServlet调用我的Intent。

Now, Im using the Alexa-SDK V2, but I don´t know how to register the servlet in this version. 现在,我正在使用Alexa-SDK V2,但我不知道如何在此版本中注册servlet。

@Configuration

public class AlexaConfig { 公共类AlexaConfig {

@Autowired
private HandlerSpeechlet handlerSpeechlet;

@Bean
public ServletRegistrationBean registerSpeechletServlet() {

    SpeechletServlet speechletServlet = new SpeechletServlet();
    speechletServlet.setSpeechlet(handlerSpeechlet);

    ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(speechletServlet, "/alexa");
    return servletRegistrationBean;
}

} }

This is my current configuration for V1, but how can I do it in V2? 这是我当前对V1的配置,但是如何在V2中进行呢?

I could fix it by following the instructions of the sample github project: 我可以按照示例github项目的说明进行修复:

https://github.com/TheSilentHorizon/spring-boot-alexa https://github.com/TheSilentHorizo​​n/spring-boot-alexa

Just implement the AlexaConfiguration.java Class and configure the application.properties 只需实现AlexaConfiguration.java类并配置application.properties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM