Skip to content

Instantly share code, notes, and snippets.

@pavankjadda
Last active April 2, 2020 04:45
Show Gist options
  • Select an option

  • Save pavankjadda/0a919fa1cf9e263364d4ae7010101b6a to your computer and use it in GitHub Desktop.

Select an option

Save pavankjadda/0a919fa1cf9e263364d4ae7010101b6a to your computer and use it in GitHub Desktop.
Sql Server with Spring Boot and Spring Data

Sql Server with Spring Boot and Spring Data

In order to use SQL server with Spring Boot and Data JPA, we need to do the following

  1. Add SQL server jdbc driver to pom.xml. Change the jre11 value to your JRE version
    <dependency>
         <groupId>com.microsoft.sqlserver</groupId>
         <artifactId>mssql-jdbc</artifactId>
         <version>8.2.2.jre11</version>
     </dependency>
    
  2. Add the following properties in application.yml file
    spring:
      application:
        name: SpringSecurity-Data-Application
      # Jpa Properties
      datasource:
        url: jdbc:sqlserver://localhost;databaseName=spring_security_data
        username: sa
        password: <your password here>
        driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    
      jpa:
        open-in-view: true
        generate-ddl: true
        properties:
          hibernate:
            ddl-auto: update
            show_sql: true
            dialect: org.hibernate.dialect.SQLServer2012Dialect
    
  3. Make sure to double check datasource URL, driver class name and hibernate.dialect properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment