0

I would like to know which dependencies I need to select inside this Spring Initializr to start an Restful API Spring Application that use Hibernate with MySQL database.

I have make some tries but unable to figure it out.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Itzik.B
  • 1,023
  • 2
  • 15
  • 35
  • Spring web + Spring Data Jpa +MySQL Driver , you can use also "Spring Boot DevTools " to avoid restarting server manually after code changes, you need to configure Hibernate and connexion with DB in the application.properties files . this answer my help you : https://stackoverflow.com/questions/25930191/connect-mysql-to-spring-application – Oussama ZAGHDOUD Oct 13 '21 at 19:42

2 Answers2

0

You will need Spring Web WEB and Spring Data JPA, and some Database Driver.

The .pom will look like this:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
Nahuel Giani
  • 540
  • 6
  • 16
0

If you are using Maven Project then add these dependencies in pom.xml,

    <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    
        <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>

If you are using Gradle Project then add these dependencies in build.gradle,

dependencies {
  implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
  implementation 'org.springframework.boot:spring-boot-starter-web'
  runtimeOnly 'mysql:mysql-connector-java'
  testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Yu Hao
  • 119,891
  • 44
  • 235
  • 294
Rose
  • 666
  • 6
  • 14