Skip to content

Instantly share code, notes, and snippets.

@sidneydemoraes
sidneydemoraes / build.gradle
Created April 27, 2017 18:58
TechTalk - Gradle + SpringBoot + Groovy - build.gradle
group 'br.com.smc'
version '0.0.1-SNAPSHOT'
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
/*maven {
url("http://inforep01.ogmaster.local:8080/nexus/content/groups/public/")
@sidneydemoraes
sidneydemoraes / gradle.tree
Created April 27, 2017 19:04
TechTalk - Gradle + Spring Boot + Groovy - Estrutura Gradle
drwxrwxr-x+ 1 Sidneyc Domain Users 0 Apr 27 10:13 gradle
drwxrwxr-x+ 1 Administradores Domain Users 0 Apr 24 15:18 .gradle
-rwxrwxr-x+ 1 Sidneyc Domain Users 5.2K Apr 27 10:13 gradlew
-rw-rw-r--+ 1 Sidneyc Domain Users 2.3K Apr 27 10:13 gradlew.bat
-rw-rw-r--+ 1 Sidneyc Domain Users 3.0K Apr 27 14:02 build.gradle
-rw-rw-r--+ 1 Sidneyc Domain Users 35 Apr 27 10:13 settings.gradle
@sidneydemoraes
sidneydemoraes / application.groovy
Last active April 27, 2017 19:11
TechTalk - Gradle + Spring Boot + Groovy - Application.groovy (Web Application)
import br.com.smc.meurumo.config.ConfigProperties
import com.paypal.base.rest.APIContext
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
import org.springframework.boot.web.servlet.ErrorPage
import org.springframework.context.annotation.Bean
import org.springframework.http.HttpStatus
@sidneydemoraes
sidneydemoraes / application.groovy
Created April 27, 2017 19:11
TechTalk - Gradle + Spring Boot + Groovy - Application.groovy (Command Line Application)
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.system.ApplicationPidFileWriter
/**
* Classe de entrada da aplicaçao SpringBoot.
*/
@sidneydemoraes
sidneydemoraes / IndexController.groovy
Created April 27, 2017 19:13
TechTalk - Gradle + Spring Boot + Groovy - Controller
import br.com.smc.meurumo.config.ConfigProperties
import br.com.smc.meurumo.domain.busca.dto.Busca
import br.com.smc.meurumo.domain.busca.service.GerenciadorDeAutoComplete
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
@sidneydemoraes
sidneydemoraes / application-production.properties
Created April 27, 2017 19:16
TechTalk - Gradle + Spring Boot + Groovy - application.properties
# ===============================
# = DATA SOURCE
# ===============================
spring.datasource.url=jdbc:mariadb://localhost:3306/mydb
spring.datasource.username=username
spring.datasource.password=passcode
spring.datasource.driverClassName = org.mariadb.jdbc.Driver
# Evitando perda de conexao com o MySql por inatividade
@sidneydemoraes
sidneydemoraes / application.yaml
Created April 27, 2017 19:19
TechTalk - Gradle + Spring Boot + Groovy - application.yaml
spring:
# ===============================
# = DATA SOURCE
# ===============================
# define DataSrouce properties
# use h2 can have a buid in web console http://localhost:8080/h2-console
datasource:
url: jdbc:mariadb://localhost:3306/mydb
driverClassName: org.mariadb.jdbc.Driver
@sidneydemoraes
sidneydemoraes / ConfigProperties.groovy
Created April 27, 2017 19:25
TechTalk - Gradle + Spring Boot + Groovy - ConfigProperties.groovy
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Configuration
@Configuration
class ConfigProperties {
@Value('${busca.parametro}')
Double raioEmKm;
@Value('${email.contato}')
@sidneydemoraes
sidneydemoraes / Estabelecimento.groovy
Created April 27, 2017 20:44
TechTalk - Gradle + Spring Boot + Groovy - JPA Entity
import br.com.smc.meurumo.domain.comercio.valueobject.CentroideEstabelecimento
import br.com.smc.meurumo.domain.comercio.valueobject.EnderecoEstabelecimento
import br.com.smc.meurumo.domain.ibge.entity.SetorCensitario
import javax.persistence.*
/**
* Entidade representando um estabelecimento comercial registrado no Brasil.
*/
@Entity
@sidneydemoraes
sidneydemoraes / EstabelecimentoRepository.groovy
Created April 27, 2017 20:45
TechTalk - Gradle + Spring Boot + Groovy - Repository com Query Nativa
import br.com.smc.meurumo.domain.comercio.entity.Estabelecimento
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.Repository
import org.springframework.data.repository.query.Param
/**
* Repositório de {@link Estabelecimento}.
*/
interface EstabelecimentoRepository extends Repository<Estabelecimento, String> {