Code Monkey home page Code Monkey logo

workshop-springdatajpa-multitenancy's Introduction

Workshop Spring Data JPA | Multitenancy

Instalação JDK 8

Extensões do VS Code:

As seguintes extensões do Visual Studio Code deverão estar instaladas:

  • Maven for Java (Microsoft)
  • Debugger for Java (Microsoft)
  • Java Test Runner (Microsoft)
  • Language Support for Java (Red Hat)
  • Java Extension Pack (Microsoft)
  • Java Dependency Viewer (Microsoft)
  • Spring Boot Extension Pack (Pivotal)
  • Lombok Annotations Support
  • REST Client

Instalação do Docker

  • Docker instalado e configurado
  • Criar o seguinte container Docker: docker run -d -p 1521:1521 -p 8080:8080 wnameless/oracle-xe-11g-r2

Instalação driver JDBC Oracle

  • Fazer o download e instalação do seguinte driver JDBC - ojdbc7.jar
  • mvn install:install-file -Dfile="ojdbc7.jar" -DgroupId="com.oracle" -DartifactId="ojdbc7" -Dversion="12.1.0" -Dpackaging=jar

Instalação do Maven

Instalar O SQL Developer e fazer o teste de conexão com o Oracle database XE 11G que esta sendo executado no container Docker.

  • hostname: localhost
  • port: 1521
  • sid: xe
  • username: system
  • password: oracle

Criar 2 usuários no Oracle Database

CREATE USER tenant1 IDENTIFIED BY 123456;
GRANT CONNECT,RESOURCE,DBA TO tenant1;
GRANT UNLIMITED TABLESPACE TO tenant1;

CREATE USER tenant2 IDENTIFIED BY 123456;
GRANT CONNECT,RESOURCE,DBA TO tenant2;
GRANT UNLIMITED TABLESPACE TO tenant2;

Lombok

https://projectlombok.org/
https://projectlombok.org/features/Data
https://projectlombok.org/features/GetterSetter
https://www.projectlombok.org/features/Builder
https://projectlombok.org/features/constructor

Principais Anotações do Spring

@Configuration
É uma annotation que indica que determinada classe possui métodos que expõe novos beans.

@Controller
Associada com classes que possuem métodos que processam requests numa aplicação web.

@Repository
Anotação que serve para definir uma classe como pertencente à camada de persistência.

@Service
Anotação que serve para definir uma classe como pertencente à camada de Serviço da aplicação.

@Autowired
A anotação @ Autowired fornece controle sobre onde e como a ligação entre os beans deve ser realizada. Pode ser usado para em métodos setter, no construtor, em uma propriedade ou métodos com nomes arbitrários e / ou vários argumentos.

Spring Boot - Interceptor

You can use the Interceptor in Spring Boot to perform operations under the following situations −

Before sending the request to the controller
Before sending the response to the client

The following are the three methods you should know about while working on Interceptors −

preHandle() method − This is used to perform operations before sending the request to the controller. This method should return true to return the response to the client.

postHandle() method − This is used to perform operations before sending the response to the client.

afterCompletion() method − This is used to perform operations after completing the request and response.

https://www.tutorialspoint.com/spring_boot/spring_boot_interceptor.htm

ThreadLocal API

https://www.baeldung.com/java-threadlocal

AbstractRoutingDataSource

https://fizzylogic.nl/2016/01/24/make-your-spring-boot-application-multi-tenant-aware-in-2-steps/
https://github.com/wmeints/spring-multi-tenant-demo
https://www.baeldung.com/spring-abstract-routing-data-source
https://github.com/Cepr0/sb-multitenant-db-demo

workshop-springdatajpa-multitenancy's People

Contributors

norberto-enomoto avatar

Watchers

 avatar

Forkers

idasilva

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.