Giter Site home page Giter Site logo

jjeanjacques10 / spring-data-jpa-demo Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 69 KB

Repository to explain Spring Data JPA concepts

Home Page: https://jjeanjacques10.medium.com/pt-br-spring-data-jpa-overview-d04fb565aa07

License: MIT License

Java 100.00%
java spring-boot spring-data-jpa

spring-data-jpa-demo's Introduction

Spring Data JPA Demo

Logo

Repository to explain Spring Data JPA concepts
Explore the article »

Report Bug · Request Feature

Jean Jacques Barros Repository size GitHub last commit License GitHub Pull Requests Stargazers

Technologies

Dependencies

<!-- Data JPA -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<!-- MySQL Connector -->
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>8.0.25</version>
</dependency>

Configuration

Access the application.properties file to configure the database.

# Database URL
spring.datasource.url=jdbc:mysql://localhost:3306/shinobidatabase
# Database User and Password
spring.datasource.username=root
spring.datasource.password=hokage
# Driver -> MySQL
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# Show SQL in terminal
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
# DDL Strategy - create, create-drop, update, validate, none
spring.jpa.hibernate.ddl-auto=update
# Convert Camelcase to Database Default
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy

Import SQL Script

Using the sql/populate.sql file, we can populate the database with some data.

spring.jpa.properties.hibernate.hbm2ddl.import_files=sql/populate-database.sql

Getting Started

Running database using docker-compose file

docker-compose up -d

Running Spring Boot Application

mvn spring-boot:run

Example of the response:

[
    {
        "id": 1,
        "name": "Naruto",
        "village": "KONOHAGAKURE"
    },
    {
        "id": 2,
        "name": "Sasuke",
        "village": "KONOHAGAKURE"
    },
    {
        "id": 3,
        "name": "Sakura",
        "village": "KONOHAGAKURE"
    },
    {
        "id": 4,
        "name": "Killer B",
        "village": "KUMOGAKURE"
    }
]

Article

Author


@jjeanjacques10

spring-data-jpa-demo's People

Contributors

jjeanjacques10 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.