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?
Asked
Active
Viewed 1,001 times
1 Answers
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"]
}

Rohit Naik
- 501
- 1
- 4
- 14
-
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? – user11702280 Oct 29 '20 at 12:46
-
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] – user11702280 Oct 29 '20 at 15:28