Skip to content

Instantly share code, notes, and snippets.

View vitorgonzaga's full-sized avatar

Vitor G Ferreira vitorgonzaga

View GitHub Profile

Keybase proof

I hereby claim:

  • I am vitorgonzaga on github.
  • I am vitorgferreira (https://keybase.io/vitorgferreira) on keybase.
  • I have a public key ASBArYipqIj2JUqMwvbeyio1G3eohgd6x6wGR8zCTPhZawo

To claim this, I am signing this object:

@vitorgonzaga
vitorgonzaga / persistence.xml
Last active March 11, 2023 00:51
persistence.xml MySQL settings
<?xml version="1.0" encoding="UTF-8" ?>
<persistence
version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
>
<persistence-unit name="loja" transaction-type="RESOURCE_LOCAL" >
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
@vitorgonzaga
vitorgonzaga / JPAUtil.java
Created March 9, 2023 14:21
JPAUtil.java
package br.com.alura.loja.util;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class JPAUtil {
private static final EntityManagerFactory FACTORY = Persistence.createEntityManagerFactory("loja");
@RestControllerAdvice
public class TratadorDeErros {
@ExceptionHandler(EntityNotFoundException.class)
public ResponseEntity tratarErro404() {
return ResponseEntity.notFound().build();
}
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity tratarErro400(MethodArgumentNotValidException ex) {
@vitorgonzaga
vitorgonzaga / SecurityConfigurations.java
Created March 28, 2023 12:32
SecurityConfigurations.java
@Configuration
@EnableWebSecurity
public class SecurityConfigurations {
@Autowired
private SecurityFilter securityFilter;
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http.csrf().disable()