Skip to content

Instantly share code, notes, and snippets.

@gilbertolptn
gilbertolptn / bootstrap-otimizado.yaml
Created Jun 3, 2022
Desabilitando metadata do Hibernate para otimizar startup da aplicação
View bootstrap-otimizado.yaml
spring:
jpa:
hibernate.ddl-auto: none
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
temp.use_jdbc_metadata_defaults: false
View podman-compose-install.sh
# From https://www.educative.io/edpresso/installing-pip3-in-ubuntu
sudo apt-get -y install python3-pip
# From https://github.com/containers/podman-compose
pip3 install podman-compose
View application-kafka.properties
spring.kafka.consumer.auto-offset-reset=earliest
spring.kafka.consumer.enable-auto-commit=true
spring.kafka.consumer.max-poll-records=100
spring.kafka.consumer.fetch-max-wait=2s
spring.kafka.listener.type=BATCH
spring.kafka.listener.concurrency=12
spring.kafka.consumer.group-id=batchTest1
spring.kafka.client-id=batchTest1
spring.kafka.listener.ack-mode=BATCH
@gilbertolptn
gilbertolptn / application.properties
Created Nov 4, 2021
Configurações de Tomcat para o Spring
View application.properties
server.error.include-stacktrace=never # when to include a stacktrace attribute (never/alway/on-trace-param)
@gilbertolptn
gilbertolptn / CustomErrorAttibutes.java
Created May 19, 2021
This classs replace default error attributes globaly on Spring MVC applications
View CustomErrorAttibutes.java
package com.example.demo.config;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;
import java.util.Map;
@Component
View RepositoryTestWithOracle.java
@DataJpaTest
@ActiveProfiles("test")
/*
By default @DataJpaTest uses embeded h2 database and ignores the connection string declared in application.properties.
This annotation disables this behavior and db configured in bootstrap.yml will be used by @DataJpaTest test.
*/
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@Sql("classpath:my_data.sql")
class MyRepositoryTest {
}
View jpa_spring_log
spring:
jpa:
show-sql: true
properties.hibernate.format_sql: true
View hibernate_log
logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
View docker.jmx.v2
docker run --rm -it -p 8080:8080 -p 9010:9010 -e JAVA_TOOL_OPTIONS='
-Xmx450M
-XX:+UseConcMarkSweepGC
-XX:NativeMemoryTracking=summary
-Djava.rmi.server.hostname=127.0.0.1
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.rmi.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false