Skip to content

Commit

Permalink
[Workaround] bypass the error of loading schema.sql while the test ca…
Browse files Browse the repository at this point in the history
…ses CountryServiceTest are run with the command mvn test or mvn package.

Ref: spring-projects/spring-boot#1454
  • Loading branch information
ezmobivietnam committed Jan 22, 2021
1 parent 3301d4d commit 1571948
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/resources/application-mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ spring.datasource.username=${MYSQL_USER:sakila}
spring.datasource.password=${MYSQL_PASS:Sakila@121}
# SQL is written to be idempotent so this is safe
#spring.datasource.initialization-mode=always
#
# JPA
spring.jpa.hibernate.ddl-auto=none
#spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
#
# Logging
logging.level.org.springframework=INFO
# logging.level.org.springframework.web=DEBUG
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
spring.profiles.active=h2
#spring.profiles.active=mysql
#
# database config
database=h2
spring.datasource.schema=classpath*:db/${database}/sakila-schema.sql
spring.datasource.data=classpath*:db/${database}/sakila-data.sql
spring.datasource.url=jdbc:h2:mem:sakila;MODE=MYSQL
spring.h2.console.enabled=true
#spring.datasource.initialization-mode=always
#
# https://github.com/spring-projects/spring-boot/issues/1454
spring.datasource.continueOnError=true
#
# JPA
spring.jpa.hibernate.ddl-auto=none
spring.jpa.open-in-view=false
#spring.jpa.show-sql=true
#
# Logging
logging.level.org.springframework=INFO
# logging.level.org.springframework.web=DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
/**
* Ref:
* https://www.baeldung.com/junit-assertions
* https://www.baeldung.com/spring-boot-exclude-auto-configuration-test
* https://javarevisited.blogspot.com/2019/04/spring-boot-error-error-creating-bean.html#axzz6jZMAb89u
* https://github.com/spring-projects/spring-boot/issues/1454
* <p>
* Created by ezmobivietnam on 2021-01-12.
*/
@SpringBootTest
//@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
class CountryServiceTest {

@MockBean
Expand Down

0 comments on commit 1571948

Please sign in to comment.