This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger: '2.0' | |
info: | |
description: API aberta para clientes e restaurantes. | |
version: '1' | |
title: AlgaFood API | |
contact: | |
name: AlgaWorks | |
url: 'https://www.algaworks.com' | |
email: [email protected] | |
host: 'localhost:8080' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="pt" xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Acesso à AlgaFood</title> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table oauth_client_details ( | |
client_id varchar(255), | |
resource_ids varchar(256), | |
client_secret varchar(256), | |
scope varchar(256), | |
authorized_grant_types varchar(256), | |
web_server_redirect_uri varchar(256), | |
authorities varchar(256), | |
access_token_validity integer, | |
refresh_token_validity integer, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fonte: https://spring.io/blog/2015/06/08/cors-support-in-spring-framework#filter-based-cors-support | |
import java.util.Collections; | |
import org.springframework.boot.web.servlet.FilterRegistrationBean; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.core.Ordered; | |
import org.springframework.web.cors.CorsConfiguration; | |
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Spring Security OAuth2 com Java 11+ lança exception: | |
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException | |
Em um projeto com Spring Boot, adicione as dependências abaixo para resolver o problema. | |
Leia também: https://stackoverflow.com/questions/52502189/java-11-package-javax-xml-bind-does-not-exist | |
--> | |
<dependency> | |
<groupId>javax.xml.bind</groupId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import javax.annotation.PostConstruct; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.hateoas.MediaTypes; | |
import org.springframework.http.MediaType; | |
import org.springframework.http.converter.HttpMessageConverter; | |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |
import org.springframework.stereotype.Component; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Referências: | |
// - https://stackoverflow.com/a/53613678 | |
// - https://tomcat.apache.org/tomcat-8.5-doc/config/http.html | |
// - https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-webserver | |
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | |
import org.springframework.boot.web.server.WebServerFactoryCustomizer; | |
import org.springframework.stereotype.Component; | |
@Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.io.InputStream; | |
import java.nio.charset.Charset; | |
import org.springframework.util.StreamUtils; | |
public class ResourceUtils { | |
public static String getContentFromResource(String resourceName) { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Baseado em: https://brightinventions.pl/blog/clear-database-in-spring-boot-tests/ | |
import java.sql.Connection; | |
import java.sql.DatabaseMetaData; | |
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
import java.sql.Statement; | |
import java.util.ArrayList; | |
import java.util.List; |
NewerOlder