Como usar o Guice com o Cloud Endpoints Frameworks
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
O Google Guice é um framework de injeção de dependência que pode ser usado com um projeto do Endpoints Frameworks v2 para configurar o mapeamento e a filtragem de servlets de maneira programática em Java, em vez de em web.xml.
Para usar Guice, você precisa adicionar a seguinte dependência pré-empacotada a pom.xml ou build.gradle. Além disso, é necessário configurar os plug-ins do Endpoints Frameworks para Maven e Gradle para definir quais classes de serviço serão usadas para criar documentos do OpenAPI.
A classe de listener cria um novo injetor que manipula o mapeamento e a filtragem de servlet, que normalmente é definido pelo web.xml, mas agora é definido pela classe EchoEndpointModule definida como:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-08 UTC."],[[["Google Guice is a dependency injection framework used in Endpoints Frameworks v2 projects to configure servlet mapping and filtering programmatically in Java."],["Using Guice requires adding the `endpoints-framework-guice` dependency to your project's `pom.xml` or `build.gradle` file and configuring the Endpoints Frameworks plugins for Maven and Gradle."],["You need to update `web.xml` to redirect all traffic from `/_ah/api/*` to the Endpoints Frameworks Guice Servlet, using the GuiceFilter class."],["An `EchoGuiceListener` class must be implemented to create an injector that handles servlet mapping and filtering, replacing the need for manual `web.xml` configuration."],["The `EchoEndpointModule` class is used to define the configurations for the servlets, including the project ID and service name, as well as binding and filtering using classes like `ServiceManagementConfigFilter` and `GoogleAppEngineControlFilter`."]]],[]]