Configuração
Habilitando a biblioteca Cloudsupport
As funcionalidades da biblioteca são habilitadas através da
anotação @EnableCloudsupport, que pode ser declarada em algum bean de
configuração do Spring. Sugere-se incluir na classe main junto com
@SpringBootApplication.
Pronto! O microsserviço já pode usufruir das funcionalidades da arquitetura.
As seções Rotinas, Integração e Segurança contêm configurações específicas para essas camadas da aplicação.
Propriedades padrão
A biblioteca ajusta algumas propriedades padrão do Spring Boot, conforme:
# ----------------------
# Startup
# ----------------------
# Hide Spring banner
spring.main.banner-mode=off
# ----------------------
# Documentation
# ----------------------
# Endpoints are disabled by default for security reasons
springdoc.swagger-ui.enabled=false
springdoc.api-docs.enabled=false
# Springdoc tag per controller is not friendly to the Feature Service pattern
springdoc.auto-tag-classes=false
# Default is '/swagger-ui.html', but Swagger redirects to '/swagger-ui'
springdoc.swagger-ui.path=/swagger-ui
# Collapsed models
springdoc.swagger-ui.defaultModelsExpandDepth=-1
springdoc.swagger-ui.defaultModelExpandDepth=2
# ----------------------
# Actuator
# ----------------------
# In Kubernetes, probes should reflect the main application (web port, connection pools, framework
# components), not the management context. To achieve this, it's a good idea to make the liveness and
# readiness probes available on the main port. Conventional probe paths are "/livez" (liveness) and
# "/readyz" (readiness). These are auto-activated when a Kubernetes environment is detected (presence
# of the env vars KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT). You can force-enable them
# regardless of environment with: "management.endpoint.health.probes.enabled=true".
# (https://docs.spring.io/spring-boot/reference/actuator/endpoints.html section "Kubernetes Probes")
management.endpoint.health.probes.add-additional-paths=true
# ----------------------
# Logging
# Note: Will take effect if using Spring Boot Log Extensions (eg: log4j2-spring.xml, not log4j2.xml)
# ----------------------
# Avoids many 'WARN DefaultHandlerExceptionResolver : Resolved'.
# Spring Boot 'spring.mvc.log-resolved-exception' does not work for all resolvers.
# (issue https://github.com/spring-projects/spring-boot/issues/29706)
logging.level.org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver=error
# Avoid the annoying warnings:
# 'WARN SpringDocAppInitializer: SpringDoc /v3/api-docs endpoint is enabled by default'
# 'WARN SpringDocAppInitializer: SpringDoc /swagger-ui endpoint is enabled by default'
# when the endpoints are explicitly enabled in a profile. Cloudsupport changes the default to disabled,
# so these warnings are unnecessary. The default is false since springdoc-openapi v2.8.14.
logging.level.org.springdoc.core.events.SpringDocAppInitializer=error
# ----------------------
# Persistence JPA
# ----------------------
# Hibernate naming strategy (CamelCase)
# The default of Spring Boot is 'org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy' (snake_case)
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
# Spring MVC defaults to creating a new JPA session per request, which can result in
# unstable behavior of services due to potential differences in JPA sessions between service flows.
# It is preferred to synchronize session creation with the @Transactional scope.
spring.jpa.open-in-view=false
# Format SQL output when SQL logging is enabled
spring.jpa.properties.hibernate.format_sql=true
Próximos Passos
Você concluiu o capítulo sobre microsserviços!
Consulte o capítulo Frontend Web ou Frontend Mobile, a respeito de implementação de frontend web ou aplicativo móvel.