0

How do I configure my Spring Boot application so that when I run unit tests it will use embedded SQL Server so that stored procedures can be executed?

1 Answer 1

0

use spring boot jpa

compile('org.springframework.boot:spring-boot-starter-data-jpa')

have a application-local.yaml config

spring:
  datasource:
    driverClassName: org.h2.Driver
    username: sa
    password: password
    url: jdbc:h2:mem:testdb;MODE=MSSQLServer;DATABASE_TO_LOWER=TRUE

MODE can be any depending upon your dev or prod db to simulate the same.

add the following in build.gradle

bootRun {
    args = ["--spring.profiles.active=local"]
}
Sign up to request clarification or add additional context in comments.

2 Comments

can you give an example/code snippet for configurations and all the properties? During application load I got syntax error for procedure execution. Is MS sql procedure execution is compatible in the above mode?
Adding to above point, stored procedures are in ms sql compatible syntax. Error is : java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement [42001-148]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.